/* Modern Soft-Neo UI Design System */

:root {
    /* Color Palette */
    --color-primary: #8C7CF0;
    /* 柔紫色 */
    --color-primary-light: #C6B9FF;
    /* 浅薰衣草紫 */
    --color-primary-dark: #7A6BE0;

    --color-accent-green: #A7F3D0;
    /* 柔绿 */
    --color-accent-yellow: #FDE68A;
    /* 柔黄 */
    --color-accent-orange: #FDBA74;
    /* 淡橙 */

    --color-bg-body: #F8F9FC;
    /* 大面积浅灰白背景 */
    --color-bg-card: #FFFFFF;
    --color-bg-sidebar: rgba(255, 255, 255, 0.85);

    --color-text-main: #2D3748;
    --color-text-muted: #718096;
    --color-text-light: #A0AEC0;

    --color-success: #34D399;
    --color-error: #FB7185;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #8C7CF0 0%, #B794F4 100%);
    --gradient-bg: linear-gradient(180deg, #F8F9FC 0%, #EDF2F7 100%);

    /* Shadows - Soft & Diffused */
    --shadow-soft: 0 10px 40px -10px rgba(140, 124, 240, 0.15);
    --shadow-card: 0 8px 24px -6px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 20px 30px -10px rgba(140, 124, 240, 0.2);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);

    /* Typography */
    --font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;

    /* Radius */
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --radius-pill: 9999px;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg-body);
    color: var(--color-text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    font-family: inherit;
}

/* Layout Structure */
.page-wrapper {
    display: flex;
    min-height: 100vh;
    background: var(--gradient-bg);
}

/* Sidebar - Left Column */
.sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    left: 20px;
    top: 20px;
    bottom: 20px;
    height: calc(100vh - 40px);
    background: var(--color-bg-sidebar);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: var(--space-xl) var(--space-md);
    text-align: center;
}

.sidebar-logo {
    width: 64px;
    height: 64px;
    background: #F1F5F9;
    border-radius: var(--radius-md);
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    box-shadow: var(--shadow-sm);
}

.sidebar-title {
    font-weight: 700;
    font-size: 18px;
    color: var(--color-text-main);
}

.sidebar-nav {
    flex: 1;
    padding: 0 var(--space-md);
    overflow-y: auto;
}

.sidebar-section-title {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--color-text-light);
    letter-spacing: 1px;
    margin: var(--space-lg) 0 var(--space-sm) var(--space-sm);
    font-weight: 600;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
}

.sidebar-item i {
    font-size: 20px;
    margin-right: 12px;
    color: var(--color-text-light);
    transition: color 0.3s ease;
}

.sidebar-item:hover {
    background: rgba(140, 124, 240, 0.05);
    color: var(--color-primary);
}

.sidebar-item:hover i {
    color: var(--color-primary);
}

.sidebar-item.active {
    background: var(--color-bg-card);
    color: var(--color-primary);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.sidebar-item.active i {
    color: var(--color-primary);
}

.sidebar-footer {
    padding: var(--space-md);
    margin: var(--space-md);
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

/* User Profile in Sidebar */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    overflow: hidden;
    border: 2px solid white;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    color: var(--color-primary);
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 12px;
    color: var(--color-text-muted);
}

.sidebar-actions {
    display: flex;
    gap: 4px;
}

.sidebar-icon-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-light);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.sidebar-icon-btn:hover {
    background: var(--color-primary-light);
    color: white;
}

/* Main Content - Center Column */
.main-wrapper {
    margin-left: 300px;
    padding: 20px;
    flex: 1;
    max-width: 1600px; /* 增加最大宽度以适配 4 列卡片 */
    width: 100%;
}

.page-content-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    /* Defined columns: Main vs Right */
    gap: 32px;
    align-items: start;
}

@media (max-width: 1200px) {
    .page-content-grid {
        grid-template-columns: 1fr;
        /* Stack on smaller screens */
    }
}

.content-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--color-text-main);
    margin-bottom: 8px;
}

.content-header p {
    color: var(--color-text-muted);
    font-size: 16px;
}

/* Cards - Floating & Soft */
.content-card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-card);
    margin-bottom: var(--space-lg);
    border: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.content-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.card-title {
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text-main);
}

/* Stats Cards */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    box-shadow: var(--shadow-card);
    transition: transform 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: var(--shadow-soft);
}

.stat-content {
    flex: 1;
}

/* ===== PAGE SECTIONS ===== */
.page-section {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.page-section.active {
    display: block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 100px 0;
    width: 100%;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3.5px solid rgba(140, 124, 240, 0.1);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    margin-bottom: 16px;
}

.loading-text {
    font-size: 14px;
    color: var(--color-text-muted);
    font-weight: 500;
    letter-spacing: 1px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== MOBILE HEADER ===== */
.mobile-header {
    display: none;
    /* Hidden by default on desktop */
    background: white;
    padding: 16px;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid #E2E8F0;
    position: sticky;
    top: 0;
    z-index: 90;
}

.mobile-menu-btn {
    border: none;
    background: transparent;
    color: var(--color-text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== OVERLAY ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 99;
}

.sidebar-overlay.show {
    display: block;
}

.stat-label {
    font-size: 14px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text-main);
}

/* Buttons */
/* Page Headers */
.content-header {
    margin-bottom: 20px;
}

.content-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--color-text-main);
    margin-bottom: 10px;
    letter-spacing: -0.5px;
}

.content-header p {
    color: var(--color-text-muted);
    font-size: 14px;
    max-width: 600px;
    line-height: 1.5;
    margin: 0;
    /* Remove default browser margins */
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-soft);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -5px rgba(140, 124, 240, 0.4);
}

.btn-secondary {
    background: white;
    color: var(--color-text-main);
    border: 1px solid #E2E8F0;
    padding: 10px 20px;
    border-radius: var(--radius-pill);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-secondary:hover {
    background: var(--color-bg-body);
    border-color: var(--color-primary-light);
    color: var(--color-primary);
}

.btn-action {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-action:hover {
    background: var(--color-primary-light);
    color: white;
}

/* User Info Grid */
.user-info-grid-6 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-lg);
    margin-top: var(--space-xl);
}

.user-info-item {
    background: var(--color-bg-body);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
}

.user-info-label {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.user-info-value {
    font-weight: 600;
    color: var(--color-text-main);
}

/* Shared Accounts & Drives Cards */
.shared-accounts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-lg);
}

.shared-account-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-card);
    transition: all 0.3s;
    border: 1px solid transparent;
    position: relative;
}

.shared-account-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--color-primary-light);
}

.shared-account-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--color-text-main);
}

.shared-account-content {
    background: var(--color-bg-body);
    padding: 12px;
    border-radius: var(--radius-md);
    font-family: monospace;
    font-size: 13px;
    color: var(--color-text-muted);
    word-break: break-all;
    margin-bottom: 16px;
    border: 1px solid #E2E8F0;
}

.shared-account-actions {
    display: flex;
    justify-content: flex-end;
}

.shared-accounts-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 桌面端默认强制 4 列 */
    gap: 20px;
}

/* 响应式断点调整 */
@media (max-width: 1400px) {
    .shared-accounts-grid {
        grid-template-columns: repeat(3, 1fr); /* 较窄屏幕降为 3 列 */
    }
}

@media (max-width: 1100px) {
    .shared-accounts-grid {
        grid-template-columns: repeat(2, 1fr); /* 平板端降为 2 列 */
    }
}

@media (max-width: 600px) {
    .shared-accounts-grid {
        grid-template-columns: 1fr; /* 手机端降为 1 列 */
    }
}

/* Auth Page */
.auth-container {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: radial-gradient(circle at top right, #E0D8FF 0%, #F5F3FF 40%, #F8F9FC 100%);
    position: relative;
    overflow: hidden;
    gap: 80px;
    /* Space between Brand and Card */
}

/* Auth Brand Side (Left/Top) */
.auth-brand-side {
    text-align: left;
    /* Default left alignment for split view */
    max-width: 400px;
    position: relative;
    z-index: 1;
}

.brand-section {
    margin-bottom: 0;
}

.brand-img {
    width: 280px;
    height: auto;
    filter: drop-shadow(0 20px 40px rgba(140, 124, 240, 0.25));
    margin-bottom: 32px;
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-20px);
    }

    100% {
        transform: translateY(0px);
    }
}

.brand-title {
    font-size: 42px;
    /* Much larger as requested */
    font-weight: 800;
    line-height: 1.2;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
    letter-spacing: -1px;
}

.brand-subtitle {
    font-size: 18px;
    color: var(--color-text-muted);
    font-weight: 500;
}

.auth-card {
    background: #FFFFFF;
    /* Pure white for contrast */
    border-radius: 40px;
    /* Very round corners */
    padding: 60px 48px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 30px 60px -12px rgba(50, 50, 93, 0.1), 0 18px 36px -18px rgba(0, 0, 0, 0.1);
    text-align: center;
    position: relative;
    z-index: 1;
    transform: translateY(0);
    transition: transform 0.4s ease;
}

/* Simplified Card Header inside Auth Card */
.auth-card .card-header h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #4A5568;
    /* Softer than black, dark gray-purple */
}

.auth-card .card-header p {
    color: #718096;
    font-size: 16px;
    margin-bottom: 40px;
    /* Increased space before button */
}

.login-notice {
    margin-top: 24px;
    /* Increased space after button */
    color: #A0AEC0;
    font-size: 14px;
}

@media (max-width: 960px) {
    .auth-container {
        flex-direction: column;
        gap: 40px;
        padding: 32px;
    }

    .auth-brand-side {
        text-align: center;
        max-width: 100%;
    }

    .brand-img {
        width: 180px;
        margin-bottom: 24px;
    }

    .brand-title {
        font-size: 32px;
    }
}

/* Shared Account Card */
/* Admin Specific */
.admin-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 4px;
}

/* User List Styling */
.user-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    background: white;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.02);
    transition: all 0.2s;
}

.user-list-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
    border-color: var(--color-primary-light);
}

.user-item-content {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.user-avatar-small {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--color-bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--color-text-light);
}

.user-details h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-main);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-meta {
    font-size: 12px;
    color: var(--color-text-muted);
    font-family: monospace;
    background: var(--color-bg-body);
    padding: 2px 6px;
    border-radius: 4px;
}

.user-quota {
    margin-top: 8px;
    font-size: 13px;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.quota-bar {
    width: 100px;
    height: 6px;
    background: var(--color-bg-body);
    border-radius: 3px;
    overflow: hidden;
}

.quota-fill {
    height: 100%;
    background: var(--color-success);
    border-radius: 3px;
}

.user-actions {
    display: flex;
    gap: 8px;
}

.admin-badge {
    background: linear-gradient(135deg, #10B981 0%, #34D399 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    font-weight: 600;
}

/* License List Styling */
.license-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: white;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0, 0, 0, 0.02);
    transition: all 0.2s;
}

.license-list-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
    border-color: var(--color-primary-light);
}

.license-info {
    flex: 1;
    min-width: 0;
    margin-right: 16px;
}

.license-key-display {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 13px;
    color: var(--color-text-main);
    background: var(--color-bg-body);
    padding: 8px 12px;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.license-meta-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.license-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.status-active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
}

.status-expired {
    background: rgba(251, 113, 133, 0.1);
    color: var(--color-error);
}

.license-actions {
    display: flex;
    gap: 8px;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(45, 55, 72, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    /* Initially hidden */
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-hover);
    border: none;
    max-width: 500px;
    width: 90%;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--color-text-light);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--color-text-main);
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--color-bg-body);
    border: 1px solid #E2E8F0;
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(140, 124, 240, 0.1);
}

/* Responsive */
@media (max-width: 1024px) {
    .main-wrapper {
        margin-left: 0;
        padding: 16px;
    }

    .sidebar {
        transform: translateX(-110%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .page-wrapper {
        flex-direction: column;
    }
}

/* Layout Utilities for 3-Column Support */
.page-content-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    /* Main content + Right sidebar */
    gap: var(--space-lg);
    align-items: start;
}

.main-column {
    min-width: 0;
    /* Prevent overflow */
}

.right-column {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    /* padding-top removed to let pages control their own alignment */
}

/* Page-specific alignment */
#page-shared-accounts .right-column,
#page-cloud-drives .right-column {
    padding-top: 68px;
}

#page-dashboard .right-column {
    padding-top: 0;
    /* Default alignment */
}

@media (max-width: 1200px) {
    .page-content-grid {
        grid-template-columns: 1fr;
    }

    .right-column {
        display: none;
        /* Auto-hide on smaller screens or stack? User said "Right side... layout", usually stack on mobile */
    }
}