/*
 * Croplod Layout (Account Shell)
 * Google Account inspired - fixed header + sidebar
 */

/* === Main Shell === */
.account-shell {
    display: flex;
    min-height: 100vh;
    flex-direction: row-reverse;
    overflow-x: hidden;
}

/* === Fixed Header === */
.account-header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: var(--z-sticky);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background-color: var(--bg-secondary);
}

/* Right side: brand */
.account-header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.account-header-brand-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.account-header-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.account-header-brand-icon svg {
    width: 18px;
    height: 18px;
}

.account-header-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.account-header-brand-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.account-header-brand-sub {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 400;
}

/* Left side: actions */
.account-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.account-header-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 150ms ease;
    position: relative;
    flex-shrink: 0;
}

.account-header-action-btn:hover {
    background-color: var(--bg-hover);
}

.account-header-action-btn:active {
    background-color: var(--bg-pressed);
}

.account-header-action-btn svg {
    width: 20px;
    height: 20px;
}

/* Notification badge */
.account-header-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-error-500);
    border: 2px solid var(--bg-primary);
}

/* Header avatar */
.account-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, var(--color-primary-400), var(--color-secondary-400));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
    cursor: pointer;
    transition: box-shadow 150ms ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.account-header-avatar:hover {
    box-shadow: 0 0 0 3px var(--bg-hover);
}

.account-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* User menu */
.account-header-user-menu {
    position: relative;
}

.account-header-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 200px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    box-shadow: var(--card-shadow-elevated);
    padding: 8px 0;
    z-index: var(--z-dropdown);
}

.account-header-dropdown.show {
    display: block;
}

.account-header-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color 150ms ease;
    text-decoration: none;
}

.account-header-dropdown-item:hover {
    background-color: var(--bg-hover);
}

.account-header-dropdown-item svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

.account-header-dropdown-divider {
    height: 1px;
    background-color: var(--border-primary);
    margin: 4px 0;
}

/* Hamburger menu button */
.account-header-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    transition: background-color 150ms ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.account-header-menu-btn:hover {
    background-color: var(--bg-hover);
}

.account-header-menu-btn:active {
    background-color: var(--bg-pressed);
}

.account-header-menu-btn svg {
    width: 22px;
    height: 22px;
}

/* === Sidebar === */
.account-sidebar {
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background-color: var(--bg-secondary);
    overflow-y: auto;
    z-index: var(--z-sidebar);
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
    overscroll-behavior: contain;
}

.account-sidebar::-webkit-scrollbar {
    width: 4px;
}

.account-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.account-sidebar::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 4px;
}

.account-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 10px;
}

/* Sidebar link */
.account-sidebar-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background-color 150ms ease, color 150ms ease;
    position: relative;
    min-height: var(--touch-target);
}

.account-sidebar-link:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.account-sidebar-link:active {
    background-color: var(--bg-pressed);
}

/* Active state */
.account-sidebar-link.active {
    background-color: var(--sidebar-bg-active);
    color: var(--sidebar-text-active);
    font-weight: 600;
}

/* Sidebar icon */
.account-sidebar-link-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Icon colors */
.account-sidebar-link[data-color="home"] .account-sidebar-link-icon { color: var(--sidebar-color-home); }
.account-sidebar-link[data-color="account"] .account-sidebar-link-icon { color: var(--sidebar-color-account); }
.account-sidebar-link[data-color="security"] .account-sidebar-link-icon { color: var(--sidebar-color-security); }
.account-sidebar-link[data-color="sessions"] .account-sidebar-link-icon { color: var(--sidebar-color-sessions); }
.account-sidebar-link[data-color="notifications"] .account-sidebar-link-icon { color: var(--sidebar-color-notifications); }
.account-sidebar-link[data-color="wallet"] .account-sidebar-link-icon { color: var(--sidebar-color-wallet); }
.account-sidebar-link[data-color="premium"] .account-sidebar-link-icon { color: var(--sidebar-color-premium); }
.account-sidebar-link[data-color="settings"] .account-sidebar-link-icon { color: var(--sidebar-color-settings); }
.account-sidebar-link[data-color="support"] .account-sidebar-link-icon { color: var(--sidebar-color-support); }
.account-sidebar-link[data-color="about"] .account-sidebar-link-icon { color: var(--sidebar-color-about); }

/* Active icon */
.account-sidebar-link.active .account-sidebar-link-icon {
    color: var(--sidebar-icon-active);
}

/* Divider */
.account-sidebar-divider {
    height: 1px;
    background-color: var(--border-subtle);
    margin: 8px 14px;
}

/* Section label */
.account-sidebar-section {
    padding: 12px 14px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    letter-spacing: var(--letter-spacing-wide);
}

/* Sidebar header (mobile only) */
.account-sidebar-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 8px;
}

.account-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.account-sidebar-brand-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.account-sidebar-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.account-sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.account-sidebar-close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 150ms ease;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.account-sidebar-close-btn:hover {
    background-color: var(--bg-hover);
}

.account-sidebar-close-btn:active {
    background-color: var(--bg-pressed);
}

.account-sidebar-close-btn svg {
    width: 20px;
    height: 20px;
}

/* === Sidebar Overlay === */
.account-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: var(--overlay);
    z-index: var(--z-sidebar-overlay);
    -webkit-tap-highlight-color: transparent;
}

.account-sidebar-overlay.active {
    display: block;
}

/* === Main Content === */
.account-main {
    flex: 1;
    margin-right: var(--sidebar-width);
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    background-color: var(--bg-secondary);
}

.account-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px;
}

/* === Page Header === */
.account-page-header {
    margin-bottom: 32px;
}

.account-page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.account-page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

/* === Dashboard Card === */
.account-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
}

.account-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.account-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

/* === Profile Hero === */
.account-profile-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 24px 40px;
    text-align: center;
}

.account-profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, var(--color-primary-400), var(--color-secondary-400));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: 700;
    color: white;
    margin-bottom: 20px;
    position: relative;
    box-shadow: var(--avatar-shadow);
}

.account-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.account-profile-avatar-edit {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--bg-card);
    border: 2px solid var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 150ms ease;
}

.account-profile-avatar-edit:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.account-profile-avatar-edit svg {
    width: 14px;
    height: 14px;
}

.account-profile-name {
    font-size: 28px;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.account-profile-email {
    font-size: 15px;
    color: var(--text-secondary);
}

/* === Search === */
.account-search {
    max-width: 560px;
    margin: 0 auto 24px;
    position: relative;
}

.account-search-input {
    width: 100%;
    height: 50px;
    padding: 0 48px 0 20px;
    font-size: 15px;
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
    border: none;
    border-radius: 28px;
    outline: none;
    transition: all 200ms ease;
    font-family: var(--font-family);
}

.account-search-input::placeholder {
    color: var(--text-tertiary);
}

.account-search-input:focus {
    background-color: var(--bg-card);
    box-shadow: var(--search-shadow-focus);
}

.account-search-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-tertiary);
    pointer-events: none;
}

/* === Chips === */
.account-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 32px;
}

.account-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    background-color: transparent;
    border: 1px solid var(--border-primary);
    border-radius: 20px;
    cursor: pointer;
    transition: all 150ms ease;
    text-decoration: none;
    font-family: var(--font-family);
    min-height: var(--touch-target);
}

.account-chip:hover {
    background-color: var(--bg-hover);
    border-color: var(--border-secondary);
}

.account-chip:active {
    background-color: var(--bg-pressed);
}

.account-chip svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

/* ============================================================
   RESPONSIVE: Tablet & Mobile
   ============================================================ */

/* Tablet/Mobile: collapse sidebar */
@media (max-width: 1023px) {
    /* CRITICAL FIX: Sidebar mobile slide-in */
    .account-sidebar {
        transform: translateX(100%);
        transition: transform 280ms cubic-bezier(0.2, 0, 0, 1);
        /* Ensure sidebar is above overlay on mobile */
        z-index: var(--z-sidebar);
    }

    .account-sidebar.open {
        transform: translateX(0);
    }

    .account-main {
        margin-right: 0;
    }

    .account-content {
        padding: 24px 20px;
    }

    .account-header-menu-btn {
        display: flex;
    }
}

/* Mobile */
@media (max-width: 639px) {
    :root {
        --header-height: 56px;
    }

    .account-content {
        padding: 20px 16px;
    }

    .account-header {
        padding: 0 16px;
    }

    .account-header-brand-sub {
        display: none;
    }

    .account-page-title {
        font-size: 20px;
    }

    .account-page-subtitle {
        font-size: 13px;
    }

    .account-profile-hero {
        padding: 28px 16px 24px;
    }

    .account-profile-avatar {
        width: 88px;
        height: 88px;
        font-size: 34px;
    }

    .account-profile-avatar-edit {
        width: 28px;
        height: 28px;
    }

    .account-profile-name {
        font-size: 22px;
    }

    .account-profile-email {
        font-size: 14px;
    }

    .account-search {
        margin-bottom: 16px;
    }

    .account-search-input {
        height: 44px;
        font-size: 14px;
        padding: 0 40px 0 16px;
    }

    .account-chips {
        gap: 8px;
        margin-bottom: 24px;
    }

    .account-chip {
        padding: 6px 14px;
        font-size: 12px;
    }

    .account-card {
        padding: 16px;
        margin-bottom: 12px;
        border-radius: 14px;
    }

    .account-card-header {
        margin-bottom: 14px;
    }

    .account-card-title {
        font-size: 15px;
    }

    .account-header-actions {
        gap: 4px;
    }

    .account-header-action-btn {
        width: 36px;
        height: 36px;
    }

    .account-header-avatar {
        width: 34px;
        height: 34px;
        font-size: 13px;
    }

    /* Sidebar mobile - full height, smooth slide */
    .account-sidebar {
        width: min(280px, 85vw);
    }

    /* Show sidebar header on mobile */
    .account-sidebar-header {
        display: flex;
    }

    /* Safe area for notch devices */
    .account-header {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .account-sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Very small screens */
@media (max-width: 359px) {
    .account-content {
        padding: 16px 12px;
    }

    .account-header {
        padding: 0 12px;
    }

    .account-card {
        padding: 14px;
        border-radius: 12px;
    }

    .account-chip {
        padding: 5px 10px;
        font-size: 11px;
    }
}
