/**
 * Bookmark Center Pro - Modal Styles
 * Modern modal design with better UX
 * 
 * @package BookmarkCenterPro
 * @version 3.0.0
 */

/* ========================================
   Modal Backdrop
======================================== */
.bcp-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: var(--bcp-z-modal-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: var(--bcp-transition-normal);
}

.bcp-modal-backdrop.open {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   Modal Container
======================================== */
.bcp-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    background: var(--bcp-glass-bg);
    backdrop-filter: var(--bcp-glass-blur);
    -webkit-backdrop-filter: var(--bcp-glass-blur);
    border: 1px solid var(--bcp-glass-border);
    border-radius: var(--bcp-radius-xl);
    box-shadow: var(--bcp-shadow-xl);
    z-index: var(--bcp-z-modal);
    opacity: 0;
    visibility: hidden;
    transition: var(--bcp-transition-smooth);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bcp-modal.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* Modal Sizes */
.bcp-modal-sm {
    max-width: 400px;
}

.bcp-modal-lg {
    max-width: 720px;
}

.bcp-modal-xl {
    max-width: 900px;
}

.bcp-modal-fullscreen {
    max-width: 95vw;
    max-height: 95vh;
    width: 95vw;
    height: 95vh;
}

/* ========================================
   Modal Header
======================================== */
.bcp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--bcp-space-4);
    padding: var(--bcp-space-5) var(--bcp-space-6);
    background: var(--bcp-bg-elevated);
    border-bottom: 1px solid var(--bcp-border-subtle);
    flex-shrink: 0;
}

.bcp-modal-title {
    display: flex;
    align-items: center;
    gap: var(--bcp-space-3);
    font-size: var(--bcp-text-xl);
    font-weight: 700;
    color: var(--bcp-text);
    margin: 0;
}

.bcp-modal-title svg {
    width: 24px;
    height: 24px;
    color: var(--bcp-primary);
}

.bcp-modal-close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--bcp-radius-md);
    color: var(--bcp-text-muted);
    cursor: pointer;
    transition: var(--bcp-transition-fast);
}

.bcp-modal-close:hover {
    background: var(--bcp-danger-bg);
    color: var(--bcp-danger);
}

.bcp-modal-close svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Modal Body
======================================== */
.bcp-modal-body {
    flex: 1;
    padding: var(--bcp-space-6);
    overflow-y: auto;
    overflow-x: hidden;
}

/* ========================================
   Modal Footer
======================================== */
.bcp-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--bcp-space-3);
    padding: var(--bcp-space-4) var(--bcp-space-6);
    background: var(--bcp-bg-elevated);
    border-top: 1px solid var(--bcp-border-subtle);
    flex-shrink: 0;
}

.bcp-modal-footer-start {
    margin-left: auto;
}

/* ========================================
   Confirmation Modal
======================================== */
.bcp-modal-confirm {
    max-width: 420px;
    text-align: center;
}

.bcp-modal-confirm .bcp-modal-body {
    padding: var(--bcp-space-8);
}

.bcp-modal-confirm-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--bcp-space-5);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--bcp-radius-full);
}

.bcp-modal-confirm-icon.danger {
    background: var(--bcp-danger-bg);
    color: var(--bcp-danger);
}

.bcp-modal-confirm-icon.warning {
    background: var(--bcp-warning-bg);
    color: var(--bcp-warning);
}

.bcp-modal-confirm-icon.success {
    background: var(--bcp-success-bg);
    color: var(--bcp-success);
}

.bcp-modal-confirm-icon svg {
    width: 32px;
    height: 32px;
}

.bcp-modal-confirm-title {
    font-size: var(--bcp-text-xl);
    font-weight: 700;
    color: var(--bcp-text);
    margin-bottom: var(--bcp-space-3);
}

.bcp-modal-confirm-message {
    font-size: var(--bcp-text-base);
    color: var(--bcp-text-secondary);
    line-height: var(--bcp-line-relaxed);
}

.bcp-modal-confirm .bcp-modal-footer {
    justify-content: center;
}

/* ========================================
   Form Modal Specific Styles
======================================== */
.bcp-modal-form .bcp-form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--bcp-space-4);
}

@media (max-width: 480px) {
    .bcp-modal-form .bcp-form-row {
        grid-template-columns: 1fr;
    }
}

/* URL Input with Fetch Button */
.bcp-url-input-wrapper {
    display: flex;
    gap: var(--bcp-space-2);
}

.bcp-url-input-wrapper .bcp-input {
    flex: 1;
}

.bcp-url-fetch-btn {
    flex-shrink: 0;
    min-width: auto;
    padding: var(--bcp-space-3) var(--bcp-space-4);
}

/* Color Picker Row */
.bcp-color-picker-row {
    display: flex;
    align-items: center;
    gap: var(--bcp-space-3);
}

.bcp-color-picker {
    width: 48px;
    height: 48px;
    padding: 0;
    border: 2px solid var(--bcp-border);
    border-radius: var(--bcp-radius-md);
    cursor: pointer;
    overflow: hidden;
}

.bcp-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.bcp-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: var(--bcp-radius-sm);
}

.bcp-color-hex-input {
    width: 120px;
    font-family: monospace;
    text-transform: uppercase;
}

/* Tags Selection */
.bcp-tags-selection {
    display: flex;
    flex-wrap: wrap;
    gap: var(--bcp-space-2);
    padding: var(--bcp-space-3);
    background: var(--bcp-input-bg);
    border: 1px solid var(--bcp-input-border);
    border-radius: var(--bcp-radius-md);
    max-height: 200px;
    overflow-y: auto;
}

.bcp-tag-option {
    display: flex;
    align-items: center;
    gap: var(--bcp-space-2);
    padding: var(--bcp-space-2) var(--bcp-space-3);
    font-size: var(--bcp-text-sm);
    color: var(--bcp-text-secondary);
    background: var(--bcp-bg-elevated);
    border: 1px solid var(--bcp-border);
    border-radius: var(--bcp-radius-full);
    cursor: pointer;
    transition: var(--bcp-transition-fast);
}

.bcp-tag-option:hover {
    background: var(--bcp-bg-hover);
    border-color: var(--bcp-border-light);
}

.bcp-tag-option.selected {
    background: var(--bcp-primary-bg);
    border-color: var(--bcp-primary);
    color: var(--bcp-primary);
}

.bcp-tag-option-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--bcp-radius-full);
    flex-shrink: 0;
}

/* Empty Tags State */
.bcp-tags-empty {
    width: 100%;
    text-align: center;
    padding: var(--bcp-space-4);
    color: var(--bcp-text-muted);
    font-size: var(--bcp-text-sm);
}

/* ========================================
   Share Modal Specific
======================================== */
.bcp-share-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--bcp-space-4);
    margin-bottom: var(--bcp-space-6);
}

.bcp-share-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--bcp-space-3);
    padding: var(--bcp-space-5);
    background: var(--bcp-bg-elevated);
    border: 1px solid var(--bcp-border);
    border-radius: var(--bcp-radius-lg);
    cursor: pointer;
    transition: var(--bcp-transition-normal);
}

.bcp-share-option:hover {
    border-color: var(--bcp-primary);
    background: var(--bcp-bg-hover);
}

.bcp-share-option-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bcp-primary-bg);
    border-radius: var(--bcp-radius-md);
    color: var(--bcp-primary);
}

.bcp-share-option-icon svg {
    width: 24px;
    height: 24px;
}

.bcp-share-option-label {
    font-size: var(--bcp-text-sm);
    font-weight: 500;
    color: var(--bcp-text);
}

/* Copy URL Result */
.bcp-share-result {
    margin-top: var(--bcp-space-6);
}

.bcp-share-result-label {
    font-size: var(--bcp-text-sm);
    font-weight: 500;
    color: var(--bcp-text-secondary);
    margin-bottom: var(--bcp-space-2);
}

.bcp-share-result-box {
    display: flex;
    align-items: center;
    gap: var(--bcp-space-2);
    padding: var(--bcp-space-3);
    background: var(--bcp-input-bg);
    border: 1px solid var(--bcp-input-border);
    border-radius: var(--bcp-radius-md);
}

.bcp-share-result-text {
    flex: 1;
    font-size: var(--bcp-text-sm);
    color: var(--bcp-text);
    font-family: monospace;
    direction: ltr;
    text-align: left;
    word-break: break-all;
    max-height: 150px;
    overflow-y: auto;
}

.bcp-share-copy-btn {
    flex-shrink: 0;
}

/* ========================================
   Manage Terms Modal (Tags/Folders/Categories)
======================================== */
.bcp-manage-term-form {
    display: flex;
    gap: var(--bcp-space-3);
    padding-bottom: var(--bcp-space-5);
    margin-bottom: var(--bcp-space-5);
    border-bottom: 1px solid var(--bcp-border-subtle);
}

.bcp-manage-term-form .bcp-input {
    flex: 1;
}

.bcp-terms-list {
    display: flex;
    flex-direction: column;
    gap: var(--bcp-space-2);
    max-height: 400px;
    overflow-y: auto;
}

.bcp-term-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--bcp-space-3);
    padding: var(--bcp-space-3) var(--bcp-space-4);
    background: var(--bcp-bg-surface);
    border: 1px solid var(--bcp-border-subtle);
    border-radius: var(--bcp-radius-md);
    transition: var(--bcp-transition-fast);
}

.bcp-term-item:hover {
    border-color: var(--bcp-border);
    background: var(--bcp-bg-hover);
}

.bcp-term-info {
    display: flex;
    align-items: center;
    gap: var(--bcp-space-3);
    flex: 1;
    min-width: 0;
}

.bcp-term-color {
    width: 16px;
    height: 16px;
    border-radius: var(--bcp-radius-full);
    flex-shrink: 0;
}

.bcp-term-details {
    flex: 1;
    min-width: 0;
}

.bcp-term-name {
    font-size: var(--bcp-text-sm);
    font-weight: 500;
    color: var(--bcp-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bcp-term-count {
    font-size: var(--bcp-text-xs);
    color: var(--bcp-text-muted);
}

.bcp-term-actions {
    display: flex;
    gap: var(--bcp-space-1);
}

.bcp-term-action {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--bcp-radius-sm);
    color: var(--bcp-text-muted);
    cursor: pointer;
    transition: var(--bcp-transition-fast);
}

.bcp-term-action:hover {
    background: var(--bcp-bg-elevated);
    color: var(--bcp-text);
}

.bcp-term-action.edit:hover {
    color: var(--bcp-primary);
}

.bcp-term-action.delete:hover {
    color: var(--bcp-danger);
    background: var(--bcp-danger-bg);
}

.bcp-term-action svg {
    width: 16px;
    height: 16px;
}

/* ========================================
   Settings Modal
======================================== */
.bcp-settings-section {
    margin-bottom: var(--bcp-space-8);
    padding-bottom: var(--bcp-space-6);
    border-bottom: 1px solid var(--bcp-border-subtle);
}

.bcp-settings-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.bcp-settings-title {
    display: flex;
    align-items: center;
    gap: var(--bcp-space-3);
    font-size: var(--bcp-text-lg);
    font-weight: 600;
    color: var(--bcp-text);
    margin-bottom: var(--bcp-space-2);
}

.bcp-settings-title svg {
    width: 22px;
    height: 22px;
    color: var(--bcp-primary);
}

.bcp-settings-description {
    font-size: var(--bcp-text-sm);
    color: var(--bcp-text-muted);
    margin-bottom: var(--bcp-space-4);
}

/* Import/Export Example Box */
.bcp-example-box {
    background: var(--bcp-bg-surface);
    border: 1px solid var(--bcp-border-subtle);
    border-radius: var(--bcp-radius-md);
    padding: var(--bcp-space-4);
    margin-top: var(--bcp-space-4);
}

.bcp-example-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--bcp-space-3);
}

.bcp-example-label {
    font-size: var(--bcp-text-sm);
    font-weight: 500;
    color: var(--bcp-text-secondary);
}

.bcp-example-code {
    background: var(--bcp-input-bg);
    border-radius: var(--bcp-radius-sm);
    padding: var(--bcp-space-3);
    font-family: monospace;
    font-size: var(--bcp-text-xs);
    color: var(--bcp-text-secondary);
    direction: ltr;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}

/* ========================================
   Responsive Modals
======================================== */
@media (max-width: 640px) {
    .bcp-modal {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        transform: translateY(100%);
    }
    
    .bcp-modal.open {
        transform: translateY(0);
    }
    
    .bcp-modal-header {
        padding: var(--bcp-space-4);
    }
    
    .bcp-modal-body {
        padding: var(--bcp-space-4);
    }
    
    .bcp-modal-footer {
        padding: var(--bcp-space-4);
    }
    
    .bcp-share-options {
        grid-template-columns: 1fr;
    }
}
