/* ============================================
   Settings Modal (Skool-style)
   ============================================ */

/* Modal backdrop */
.settings-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1070;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.settings-modal-backdrop.is-open {
    opacity: 1;
    visibility: visible;
}

/* Modal container */
.settings-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 95%;
    max-width: 1040px;
    height: min(720px, 90vh);
    background: var(--color-card-bg);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    z-index: 1071;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    overflow: hidden;
}

.settings-modal.is-open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* Modal header */
.settings-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    color: #fff;
}

.settings-modal-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.settings-modal-logo {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.settings-modal-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Logo upload preview in branding tab */
.settings-logo-preview {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    font-size: 1.5rem;
    color: var(--color-text-light, #6c757d);
    border: 1px solid var(--bs-border-color, #dee2e6);
}

.settings-logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.settings-modal-title-group {
    display: flex;
    flex-direction: column;
}

.settings-modal-org-name-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-modal-org-name {
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.2;
}

.settings-modal-edit-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    border-radius: 4px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.settings-modal-edit-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

.settings-modal-name-input {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.2;
    padding: 0.15rem 0.5rem;
    outline: none;
    width: 220px;
}

.settings-modal-name-input:focus {
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.2);
}

.settings-modal-org-code {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    opacity: 0.75;
    cursor: pointer;
    padding: 0.1rem 0.4rem;
    margin-left: -0.4rem;
    border-radius: 4px;
    transition: opacity 0.15s ease, background-color 0.15s ease;
    font-family: monospace;
    letter-spacing: 0.05em;
    align-self: flex-start;
}

.settings-modal-org-code:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}

.settings-modal-org-code .bi {
    font-size: 0.75rem;
}

.settings-modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-modal-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Modal body - two column layout */
.settings-modal-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Left navigation */
.settings-modal-nav {
    width: 160px;
    flex-shrink: 0;
    background: #f8f9fa;
    border-right: 1px solid var(--color-border);
    padding: 1rem 0;
    overflow-y: auto;
}

.settings-nav-item {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 500;
    color: #4b5563;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    font-family: var(--font-family);
    white-space: nowrap;
}

.settings-nav-item:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--color-text);
}

.settings-nav-item.is-active {
    background: var(--color-card-bg);
    color: var(--brand-primary);
    font-weight: 600;
    border-right: 3px solid var(--brand-primary);
    padding-right: calc(1rem - 3px);
}

/* Right content area */
.settings-modal-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    min-height: 0;
}

.settings-panel {
    display: none;
}

.settings-panel.is-active {
    display: block;
}

/* Settings form sections */
.settings-section {
    margin-bottom: 2rem;
}

.settings-section:last-child {
    margin-bottom: 0;
}

/* Color picker row */
.settings-color-row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.settings-color-field {
    flex: 1;
    min-width: 150px;
}

.settings-color-input-group {
    display: flex;
    gap: 0.5rem;
}

.settings-color-input-group input[type="color"] {
    width: 44px;
    height: 44px;
    padding: 4px;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    cursor: pointer;
}

.settings-color-input-group input[type="text"] {
    flex: 1;
}

/* Panel header with label and action */
.settings-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
}

.settings-section-label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
}

/* Divider between sections */
.settings-divider {
    height: 1px;
    background: var(--color-border);
    margin: 1.5rem 0;
}

/* Vocabulary actions row */
.settings-vocab-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-vocab-actions .form-select {
    width: auto;
    min-width: 160px;
}

.settings-preset-buttons {
    display: flex;
    gap: 0.35rem;
}

/* Vocabulary table */
.settings-vocab-table {
    margin-bottom: 0;
}

.settings-vocab-table th {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6b7280;
    border-bottom-width: 1px;
}

.settings-vocab-table td {
    vertical-align: middle;
    border-bottom: 1px solid var(--color-border);
}

.settings-vocab-table td:first-child {
    font-weight: 500;
    color: var(--color-text);
    width: 120px;
}

.settings-vocab-table tbody tr:last-child td {
    border-bottom: none;
}

/* Vocabulary preview state */
.settings-vocab-table input.is-preview {
    background-color: #fef3c7;
    border-color: #f59e0b;
}

/* Dashboard panel */
.settings-dashboard-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.settings-dashboard-stats .stat-card {
    flex: 1;
    min-width: 0;
}

.settings-dashboard-chart {
    height: 280px;
    position: relative;
    overflow: hidden;
}

.settings-dashboard-chart canvas {
    width: 100% !important;
    height: 240px !important;
}

/* Integration items */
.settings-integration-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.settings-integration-item:last-child {
    margin-bottom: 0;
}

.settings-integration-info {
    flex: 1;
    min-width: 0;
}

.settings-integration-info strong {
    display: block;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.settings-integration-info small {
    color: #6b7280;
}

/* ============================================
   Availability Tab (Working Hours Grid)
   ============================================ */

.settings-avail-hours-grid {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.settings-avail-day-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid #f3f4f6;
}

.settings-avail-day-row:last-child {
    border-bottom: none;
}

.settings-avail-day-label {
    width: 80px;
    flex-shrink: 0;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--color-text);
}

.settings-avail-day-rules {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    flex: 1;
}

.settings-avail-add-btn {
    background: none;
    border: 1px dashed #d1d5db;
    border-radius: 6px;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.15rem 0.5rem;
    font-size: 0.85rem;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.settings-avail-add-btn:hover {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.settings-avail-add-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

/* Tablet: horizontal pill nav, centered modal */
@media (max-width: 900px) {
    .settings-modal {
        height: min(720px, 95vh);
    }

    .settings-modal-header {
        padding: 1rem 1.25rem;
    }

    .settings-modal-logo {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        font-size: 1rem;
    }

    .settings-modal-logo img {
        border-radius: 50%;
    }

    .settings-modal-org-name {
        font-size: 1rem;
    }

    .settings-modal-body {
        flex-direction: column;
    }

    .settings-modal-nav {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        padding: 0.5rem;
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 0.25rem;
    }

    .settings-nav-item {
        flex-shrink: 0;
        padding: 0.5rem 1rem;
        border-radius: 999px;
        white-space: nowrap;
    }

    .settings-nav-item.is-active {
        background: var(--brand-primary);
        color: #fff;
        border-right: none;
        padding-right: 1rem;
    }

    .settings-modal-content {
        padding: 1rem;
        flex: 1;        /* Fill remaining column space after horizontal nav */
        min-height: 0;  /* Allow scroll instead of expanding beyond parent */
    }

    .settings-color-row {
        flex-direction: column;
        gap: 1rem;
    }

    .settings-color-field {
        min-width: 100%;
    }

    .settings-panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* Mobile: full-screen takeover */
@media (max-width: 576px) {
    .settings-modal {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        top: 0;
        left: 0;
        transform: translateY(100%);
    }

    .settings-modal.is-open {
        transform: translateY(0);
    }

    .settings-modal-header {
        padding: 0.75rem 1rem;
    }

    .settings-modal-header-left {
        gap: 0.75rem;
    }

    .settings-modal-logo {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        font-size: 0.9rem;
    }

    .settings-modal-logo img {
        border-radius: 50%;
    }

    .settings-modal-org-name {
        font-size: 0.95rem;
    }

    .settings-modal-org-code {
        font-size: 0.7rem;
    }
}
