/* AubeDrive - Theme & Variables */
:root {
    --bg: #f8f9fc;
    --bg2: #ffffff;
    --bg3: #f0f1f5;
    --bg4: #e8e9f0;
    --text: #1a1c2e;
    --text2: #4a4d6a;
    --text3: #8a8da8;
    --accent: #4f8ef7;
    --accent2: #3a6fd8;
    --accent-soft: rgba(79, 142, 247, 0.08);
    --border: #e2e5ed;
    --border2: #d0d3e0;
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.08);
    --success: #22c55e;
    --warning: #f59e0b;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
    --sidebar-width: 240px;
    --header-height: 56px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="dark"] {
    --bg: #0f1117;
    --bg2: #161822;
    --bg3: #1e2030;
    --bg4: #262840;
    --text: #e2e4f0;
    --text2: #a0a4c0;
    --text3: #6b6f8a;
    --border: #2a2d42;
    --border2: #363a54;
    --accent-soft: rgba(79, 142, 247, 0.12);
    --danger-soft: rgba(239, 68, 68, 0.12);
    --shadow: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.3);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.screen { height: 100vh; }

/* ---- Login ---- */
.login-container {
    max-width: 380px;
    margin: 0 auto;
    padding: 80px 24px 24px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo svg { margin: 0 auto 12px; display: block; }
.login-logo h1 { font-size: 26px; font-weight: 700; color: var(--text); }
.login-subtitle { color: var(--text3); font-size: 14px; margin-top: 4px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }

.input, .form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg2);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    transition: border-color 0.15s;
}

.input:focus, .form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.error-msg {
    color: var(--danger);
    font-size: 13px;
    padding: 8px 12px;
    background: var(--danger-soft);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.login-footer {
    text-align: center;
    font-size: 13px;
    color: var(--text3);
    margin-top: 20px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
    background: var(--bg3);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg4); }

.btn-full { width: 100%; justify-content: center; padding: 11px; }

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text2);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg3); color: var(--text); }

.btn-upload {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius);
    font-size: 15px;
    margin-bottom: 16px;
    justify-content: center;
    box-shadow: var(--shadow);
}

/* ---- Header ---- */
.header {
    height: var(--header-height);
    border-bottom: 1px solid var(--border);
    background: var(--bg2);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 200px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
}

.header-center { flex: 1; max-width: 680px; }

.search-bar {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text3);
}

.search-bar input {
    width: 100%;
    padding: 9px 14px 9px 42px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--bg3);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    transition: all 0.15s;
}

.search-bar input:focus {
    outline: none;
    background: var(--bg2);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-dropdown {
    position: absolute;
    top: 44px;
    right: 0;
    width: 280px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    z-index: 200;
}

.user-info { margin-bottom: 12px; }
.user-info strong { display: block; font-size: 14px; }
.user-info span { font-size: 13px; color: var(--text3); }

.storage-info { margin-bottom: 8px; }
.storage-bar {
    height: 6px;
    background: var(--bg3);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}
.storage-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s;
}
.storage-info span { font-size: 12px; color: var(--text3); }

.dropdown-item {
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    border-radius: var(--radius-sm);
    text-align: left;
}
.dropdown-item:hover { background: var(--bg3); }

.user-dropdown hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0;
}

/* ---- Layout ---- */
.main-layout {
    display: flex;
    height: calc(100vh - var(--header-height));
}

.sidebar {
    width: var(--sidebar-width);
    border-right: 1px solid var(--border);
    padding: 16px;
    background: var(--bg2);
    overflow-y: auto;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border: none;
    background: none;
    color: var(--text2);
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    border-radius: var(--radius-sm);
    width: 100%;
    text-align: left;
    transition: all 0.1s;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

/* ---- Content ---- */
.content {
    flex: 1;
    padding: 16px 24px;
    overflow-y: auto;
    position: relative;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.crumb {
    background: none;
    border: none;
    color: var(--text2);
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}
.crumb:hover { background: var(--bg3); color: var(--text); }
.crumb:last-child { color: var(--text); font-weight: 500; }

.breadcrumb .separator { color: var(--text3); font-size: 12px; }

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

/* Grid view */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.grid.list-view {
    grid-template-columns: 1fr;
    gap: 2px;
}

/* File/Folder Cards */
.file-card, .folder-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.file-card:hover, .folder-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.folder-card {
    display: flex;
    align-items: center;
    gap: 10px;
}

.folder-icon {
    color: var(--accent);
    flex-shrink: 0;
}

.folder-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-preview {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg3);
}

.file-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.file-type-icon {
    font-size: 32px;
    color: var(--text3);
    font-weight: 600;
    text-transform: uppercase;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.file-meta {
    font-size: 12px;
    color: var(--text3);
}

/* List view cards */
.list-view .file-card, .list-view .folder-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
}

.list-view .file-preview {
    width: 40px;
    height: 40px;
    margin-bottom: 0;
    flex-shrink: 0;
}

.list-view .file-type-icon { font-size: 14px; }

.list-view .file-info { flex: 1; min-width: 0; }
.list-view .file-name { margin-bottom: 0; }
.list-view .file-meta { display: flex; gap: 16px; }
.list-view .file-size { min-width: 80px; }

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--text3);
}
.empty-state svg { margin: 0 auto 12px; display: block; }
.empty-state p { font-size: 15px; }

/* ---- Loading ---- */
.loading { text-align: center; padding: 40px; }
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Drop Zone ---- */
.drop-overlay {
    position: absolute;
    inset: 0;
    background: var(--accent-soft);
    border: 2px dashed var(--accent);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.drop-message {
    text-align: center;
    color: var(--accent);
}
.drop-message svg { margin: 0 auto 8px; }
.drop-message p { font-size: 16px; font-weight: 500; }

/* ---- Modals ---- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--bg2);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 0 0;
}

/* Preview Modal */
.preview-content {
    width: min(90vw, 900px);
    height: min(85vh, 700px);
    display: flex;
    flex-direction: column;
}

.modal-actions { display: flex; gap: 4px; }

.preview-body {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg);
}

.preview-body img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.preview-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: var(--radius-sm);
}

.preview-body pre {
    width: 100%;
    max-height: 100%;
    overflow: auto;
    padding: 16px;
    background: var(--bg2);
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Share Modal */
.share-content {
    width: min(90vw, 480px);
}

.share-body { padding: 20px; }
.share-section { margin-bottom: 20px; }
.share-section h4 { font-size: 13px; color: var(--text2); margin-bottom: 8px; }

.share-user-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.share-user-form .input { flex: 1; }

.select-sm {
    width: auto;
    padding: 8px 10px;
    min-width: 130px;
}

.share-link-section { display: flex; flex-direction: column; gap: 8px; }

#share-link-display {
    display: flex;
    gap: 8px;
}

#share-link-display .input { flex: 1; font-size: 12px; }

.share-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.share-item:last-child { border: none; }
.share-item .share-user-info { color: var(--text2); }

/* Folder Modal */
.folder-content {
    width: min(90vw, 400px);
    padding: 0 0 16px;
}
.folder-content form { padding: 16px 20px; }

/* ---- Context Menu ---- */
.context-menu {
    position: fixed;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 300;
    min-width: 180px;
}

.context-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    border-radius: var(--radius-sm);
    text-align: left;
}

.context-menu button:hover { background: var(--bg3); }
.context-menu button.danger { color: var(--danger); }
.context-menu button.danger:hover { background: var(--danger-soft); }
.context-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ---- Upload Menu ---- */
.upload-menu {
    position: fixed;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 300;
    min-width: 220px;
}

.upload-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.upload-menu button:hover { background: var(--bg3); }

/* ---- Upload Progress ---- */
.upload-progress {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 14px;
    z-index: 400;
}

.upload-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
}

.upload-progress-bar {
    height: 4px;
    background: var(--bg3);
    border-radius: 2px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s;
    width: 0;
}

/* ---- Toasts ---- */
#toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 600;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 20px;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.2s ease-out;
    white-space: nowrap;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Plan Alert Banner ---- */
.plan-alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.plan-alert.warning { background: rgba(245, 158, 11, 0.1); border: 1px solid var(--warning); color: var(--warning); }
.plan-alert.danger { background: var(--danger-soft); border: 1px solid var(--danger); color: var(--danger); }
.plan-alert.info { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent); }
.plan-alert .alert-text { flex: 1; }
.plan-alert .btn { flex-shrink: 0; font-size: 13px; padding: 6px 14px; }

/* ---- Notifications ---- */
.notif-btn { position: relative; }
.notif-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}
.notif-dropdown {
    position: fixed;
    top: var(--header-height);
    right: 16px;
    width: 360px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    padding: 8px;
}
.notif-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border-left: 3px solid transparent;
    margin-bottom: 4px;
}
.notif-item:hover { background: var(--bg3); }
.notif-item.unread { border-left-color: var(--accent); background: var(--accent-soft); }
.notif-item .notif-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.notif-item .notif-msg { font-size: 12px; color: var(--text2); line-height: 1.4; }
.notif-item .notif-time { font-size: 11px; color: var(--text3); margin-top: 4px; }
.notif-empty { text-align: center; padding: 24px; color: var(--text3); font-size: 13px; }
.notif-header { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.notif-header h4 { font-size: 14px; }
.notif-header button { font-size: 12px; color: var(--accent); background: none; border: none; cursor: pointer; font-family: var(--font); }

/* ---- Plans Page ---- */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.plan-card {
    background: var(--bg2);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    transition: all 0.15s;
}
.plan-card:hover { border-color: var(--accent); }
.plan-card.current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.plan-card .plan-name { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.plan-card .plan-price { font-size: 28px; font-weight: 700; color: var(--accent); margin: 12px 0; }
.plan-card .plan-price span { font-size: 14px; font-weight: 400; color: var(--text3); }
.plan-card .plan-quota { font-size: 14px; color: var(--text2); margin-bottom: 16px; }
.plan-card .btn { width: 100%; }
.plan-card.recommended { border-color: var(--accent); position: relative; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        z-index: 90;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .header-center { display: none; }
    .header-left { min-width: auto; }
    .content { padding: 12px 16px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
}

@media (max-width: 480px) {
    .grid { grid-template-columns: 1fr 1fr; }
    .share-user-form { flex-direction: column; }
}
