/* ============================================
   BUSINESS DOM — Espace Client
   App-style layout (sidebar + content)
   Prefix: .ec-*
   ============================================ */

/* ============================================
   BODY / RESET (overrides main site spacing)
   ============================================ */
body.ec-body {
    background: var(--gray-50);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================
   STATE VISIBILITY (state machine driven)
   !important wins over any partial inline-style or rogue rule
   ============================================ */
.ec-state {
    display: none !important;
}

.ec-state.is-active {
    display: block !important;
}

.ec-state.ec-dashboard-wrap.is-active {
    display: grid !important;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */
.ec-sidebar {
    background: var(--black);
    color: rgba(255, 255, 255, 0.85);
    padding: 28px 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.ec-sidebar__brand {
    padding: 0 24px 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 20px;
}

.ec-sidebar__logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--white);
    text-decoration: none;
    margin-bottom: 6px;
}

.ec-sidebar__logo-tricolor {
    width: 4px;
    height: 22px;
    background: linear-gradient(to bottom,
        var(--bd-blue) 0% 33.33%,
        var(--white) 33.33% 66.66%,
        var(--bd-red) 66.66% 100%);
    border-radius: 1px;
}

.ec-sidebar__logo-text {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 1.5px;
}

.ec-sidebar__subtitle {
    display: block;
    font-size: 0.7rem;
    color: var(--bd-red);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 600;
    margin-top: 6px;
    padding-left: 14px;
}

.ec-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 14px;
    flex: 1;
}

.ec-sidebar__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s var(--ease);
    position: relative;
}

.ec-sidebar__link svg {
    flex-shrink: 0;
    opacity: 0.75;
}

.ec-sidebar__link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--white);
}

.ec-sidebar__link:hover svg {
    opacity: 1;
}

.ec-sidebar__link.is-active {
    background: rgba(201, 23, 31, 0.15);
    color: var(--white);
    border-left: 2px solid var(--bd-red);
    padding-left: 12px;
}

.ec-sidebar__link.is-active svg {
    opacity: 1;
    color: var(--bd-red);
}

.ec-sidebar__badge {
    margin-left: auto;
    background: var(--bd-red);
    color: var(--white);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 100px;
    min-width: 18px;
    text-align: center;
}

.ec-sidebar__badge:empty,
.ec-sidebar__badge[data-count="0"] {
    display: none;
}

.ec-sidebar__footer {
    padding: 20px 14px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ec-sidebar__user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.ec-sidebar__avatar {
    width: 36px;
    height: 36px;
    background: var(--bd-red);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.ec-sidebar__user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ec-sidebar__user-info strong {
    color: var(--white);
    font-size: 0.8125rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ec-sidebar__user-info span {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ec-sidebar__logout {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s var(--ease);
    flex-shrink: 0;
}

.ec-sidebar__logout:hover {
    background: var(--bd-red);
    color: var(--white);
    border-color: var(--bd-red);
}

/* ============================================
   CONTENT AREA
   ============================================ */
.ec-content {
    min-height: 100vh;
    padding: 0;
    background: var(--gray-50);
    overflow-x: hidden;
}

.ec-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 36px;
    background: var(--white);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 50;
}

.ec-topbar__title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.ec-topbar__burger {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.ec-topbar__burger span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--gray-700);
}

/* ============================================
   SECTIONS (dashboard content)
   ============================================ */
.ec-section {
    display: none;
    padding: 36px;
    max-width: 1200px;
    margin: 0 auto;
}

.ec-section.is-active {
    display: block;
    animation: ecFadeIn 0.3s var(--ease);
}

@keyframes ecFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   COMMON COMPONENTS (shared by all sections)
   ============================================ */
.ec-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 20px;
}

.ec-card__title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.ec-card__subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.ec-section-header {
    margin-bottom: 28px;
}

.ec-section-header__title {
    font-family: var(--font-display);
    font-size: 1.875rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.ec-section-header__desc {
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

/* Forms — shared styles for all sections */
.ec-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.ec-field label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    font-weight: 600;
    text-transform: uppercase;
}

.ec-field label .ec-required {
    color: var(--bd-red);
    margin-left: 2px;
}

.ec-field input,
.ec-field select,
.ec-field textarea {
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: border-color 0.2s var(--ease);
    width: 100%;
}

.ec-field input:focus,
.ec-field select:focus,
.ec-field textarea:focus {
    outline: none;
    border-color: var(--bd-red);
    box-shadow: 0 0 0 3px var(--bd-red-glow);
}

.ec-field textarea {
    resize: vertical;
    min-height: 100px;
}

.ec-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Status badges */
.ec-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.ec-badge--success {
    background: rgba(74, 222, 128, 0.12);
    color: #14a44a;
}

.ec-badge--warning {
    background: rgba(245, 158, 11, 0.12);
    color: #b45309;
}

.ec-badge--info {
    background: var(--bd-red-glow);
    color: var(--bd-red);
}

.ec-badge--neutral {
    background: var(--gray-100);
    color: var(--gray-700);
}

/* Empty state */
.ec-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.ec-empty__icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    color: var(--gray-400);
}

.ec-empty__title {
    font-family: var(--font-display);
    font-size: 1.125rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* ============================================
   AUTH STATE — Centered card layout
   (Used by login + reset password)
   ============================================ */
#state-login.is-active,
#state-reset-password.is-active,
#state-onboarding-form.is-active,
#state-onboarding-docs.is-active,
#state-pending.is-active {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.ec-auth-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.08), 0 2px 12px rgba(0, 0, 0, 0.04);
    padding: 48px 40px;
    max-width: 440px;
    width: 100%;
    border: 1px solid var(--border-light);
}

.ec-auth-card__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 8px;
}

.ec-auth-card__brand-tricolor {
    width: 3px;
    height: 18px;
    background: linear-gradient(to bottom,
        var(--bd-blue) 0% 33.33%,
        var(--white) 33.33% 66.66%,
        var(--bd-red) 66.66% 100%);
    border-radius: 1px;
}

.ec-auth-card__brand-text {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 1.5px;
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* ============================================
   TOAST notifications
   ============================================ */
.ec-toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.ec-toast {
    background: var(--black);
    color: var(--white);
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
    max-width: 360px;
    pointer-events: auto;
    animation: ecToastIn 0.3s var(--ease), ecToastOut 0.3s var(--ease) 3.7s forwards;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ec-toast--success {
    background: #14a44a;
}

.ec-toast--error {
    background: var(--bd-red);
}

@keyframes ecToastIn {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes ecToastOut {
    to { transform: translateX(20px); opacity: 0; }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .ec-state.ec-dashboard-wrap.is-active {
        grid-template-columns: 1fr;
    }

    .ec-sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        z-index: 1000;
        width: 260px;
        transition: left 0.3s var(--ease);
    }

    .ec-sidebar.is-open {
        left: 0;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.25);
    }

    .ec-topbar__burger {
        display: flex;
    }

    .ec-section {
        padding: 24px 20px;
    }

    .ec-auth-card {
        padding: 32px 24px;
    }

    .ec-field-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   RESPONSIVE — 768px (tablette portrait / mobile paysage)
   ============================================ */
@media (max-width: 768px) {
    /* Topbar */
    .ec-topbar {
        padding: 14px 16px;
    }

    .ec-topbar__title {
        font-size: 1.25rem;
    }

    /* Section */
    .ec-section {
        padding: 20px 16px;
    }

    /* Section headers */
    .ec-section-header__title {
        font-size: 1.5rem;
    }

    /* Cards */
    .ec-card {
        padding: 20px 16px;
    }

    /* Profile layout — sidebar nav → horizontal scroll */
    .ec-prof-layout {
        grid-template-columns: 1fr;
    }

    .ec-prof-sidenav {
        position: static;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 4px;
        padding: 8px;
        scrollbar-width: none;
        -ms-overflow-style: none;
        border-radius: var(--radius-sm);
    }

    .ec-prof-sidenav::-webkit-scrollbar {
        display: none;
    }

    .ec-prof-tab {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 9px 14px;
        font-size: 0.8125rem;
    }

    /* Notifications — compact gap */
    .ec-notif-list {
        gap: 6px;
    }

    .ec-notif-item {
        padding: 12px;
    }

    .ec-notif-desc {
        display: none;
    }

    /* Modals (mail + doc) — bottom sheet on mobile */
    .ec-mail-modal {
        align-items: flex-end;
    }

    .ec-mail-modal__card {
        max-width: 100%;
        width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 92vh;
        overflow-y: auto;
    }

    .ec-doc-modal {
        align-items: flex-end;
        padding: 0;
    }

    .ec-doc-modal__card {
        max-width: 100%;
        width: 100%;
        max-height: 92vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    /* Reservations modal */
    .ec-res-modal {
        align-items: flex-end;
        padding: 0;
    }

    .ec-res-modal__box {
        max-width: 100%;
        width: 100%;
        max-height: 92vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    /* Toast — full width on mobile */
    .ec-toast-container {
        bottom: 16px;
        right: 12px;
        left: 12px;
    }

    .ec-toast {
        max-width: 100%;
    }
}

/* ============================================
   RESPONSIVE — 480px (petit mobile)
   ============================================ */
@media (max-width: 480px) {
    /* Auth card */
    .ec-auth-card {
        padding: 24px 20px;
    }

    /* Section */
    .ec-section {
        padding: 16px 12px;
    }

    /* Section header */
    .ec-section-header__title {
        font-size: 1.25rem;
    }

    /* Topbar */
    .ec-topbar {
        padding: 12px;
        gap: 10px;
    }

    .ec-topbar__title {
        font-size: 1.1rem;
    }

    /* Cards */
    .ec-card {
        padding: 16px 14px;
    }

    /* Notification items: reduce padding */
    .ec-notif-item {
        padding: 10px 12px;
        gap: 10px;
    }

    .ec-notif-icon {
        width: 34px;
        height: 34px;
        flex-shrink: 0;
    }

    .ec-notif-title {
        font-size: 0.875rem;
    }

    .ec-notif-date {
        font-size: 0.7rem;
    }

    /* Profile tabs — smaller font */
    .ec-prof-tab {
        padding: 8px 12px;
        font-size: 0.78rem;
    }

    /* Profile layout actions — stack vertically */
    .ec-prof-actions {
        flex-direction: column;
    }

    .ec-prof-actions .btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    /* Doc and mail preview modals */
    .ec-mail-modal__card,
    .ec-doc-modal__card,
    .ec-res-modal__box {
        max-height: 96vh;
    }

    /* Toast */
    .ec-toast-container {
        bottom: 12px;
        right: 8px;
        left: 8px;
    }

    .ec-toast {
        padding: 12px 16px;
        font-size: 0.8125rem;
    }
}
