/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:          #0f0f0f;
    --bg-2:        #1a1a1a;
    --bg-3:        #222;
    --border:      #2a2a2a;
    --border-2:    #333;
    --text:        #f0f0f0;
    --text-2:      #aaa;
    --text-3:      #666;
    --primary:     #667eea;
    --primary-2:   #764ba2;
    --accent:      #f093fb;
    --success:     #43e97b;
    --danger:      #f5576c;
    --warning:     #f9a825;
    --sidebar-w:   260px;
    --sidebar-w-sm: 70px;
    --radius:      12px;
    --radius-sm:   8px;
    --transition:  .2s ease;
    --shadow:      0 4px 24px rgba(0,0,0,.5);
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ===== LINKS ===== */
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent); }

/* ===== LAYOUT ===== */
.app-wrapper { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 200;
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    min-height: 80px;
}

.sidebar-logo .logo-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; color: #fff;
    flex-shrink: 0;
}

.sidebar-logo .logo-text {
    font-weight: 700;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    position: relative;
    font-size: 0.9rem;
}

.nav-item i { width: 20px; text-align: center; font-size: 1rem; flex-shrink: 0; }

.nav-item:hover,
.nav-item.active {
    background: linear-gradient(135deg, rgba(102,126,234,.15), rgba(118,75,162,.1));
    color: var(--primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 60%;
    background: linear-gradient(var(--primary), var(--primary-2));
    border-radius: 0 3px 3px 0;
}

.sidebar-bottom {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
}

.nav-label { overflow: hidden; }

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    transition: margin-left var(--transition);
    display: flex;
    flex-direction: column;
}

/* ===== TOPBAR ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 64px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.hamburger {
    display: none;
    background: none; border: none;
    color: var(--text); font-size: 1.2rem;
    cursor: pointer; padding: 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.hamburger:hover { background: var(--bg-3); }

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; color: #fff; font-weight: 600;
}

/* ===== PAGE BODY ===== */
.page-body { padding: 28px 24px; flex: 1; }

/* ===== CARDS ===== */
.card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: border-color var(--transition), transform var(--transition);
}
.card:hover { border-color: var(--border-2); }

/* ===== STAT CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(102,126,234,.05), transparent);
    pointer-events: none;
}
.stat-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}
.stat-icon.photos  { background: rgba(102,126,234,.15); color: var(--primary); }
.stat-icon.videos  { background: rgba(240,147,251,.15); color: var(--accent); }
.stat-icon.files   { background: rgba(249,168,37,.15);  color: var(--warning); }
.stat-icon.folders { background: rgba(67,233,123,.15);  color: var(--success); }
.stat-icon.storage { background: rgba(245,87,108,.15);  color: var(--danger); }

.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-2); }

/* ===== SECTION HEADER ===== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.section-title { font-size: 1rem; font-weight: 600; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: #fff;
    box-shadow: 0 2px 12px rgba(102,126,234,.4);
}
.btn-primary:hover { opacity: .9; transform: translateY(-1px); color: #fff; }
.btn-secondary { background: var(--bg-3); color: var(--text); border: 1px solid var(--border-2); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: rgba(245,87,108,.15); color: var(--danger); border: 1px solid rgba(245,87,108,.3); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { padding: 8px; width: 34px; height: 34px; justify-content: center; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; margin-bottom: 6px; font-size: 0.875rem; color: var(--text-2); font-weight: 500; }
.form-control {
    width: 100%;
    background: var(--bg-3);
    border: 1px solid var(--border-2);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: border-color var(--transition);
    outline: none;
}
.form-control:focus { border-color: var(--primary); }
.form-control::placeholder { color: var(--text-3); }
select.form-control { cursor: pointer; }

/* ===== GALLERY GRID ===== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.photo-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--transition);
    cursor: pointer;
}
.photo-card:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: var(--shadow); }

.photo-thumb {
    width: 100%; aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
    background: var(--bg-3);
}

.photo-info { padding: 12px; }
.photo-name { font-size: 0.8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-meta { font-size: 0.72rem; color: var(--text-2); margin-top: 4px; }
.photo-actions { display: flex; gap: 6px; margin-top: 10px; }

/* ===== REELS ===== */
.reels-list { display: flex; flex-direction: column; gap: 20px; max-width: 720px; margin: 0 auto; }

.reel-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color var(--transition);
}
.reel-card:hover { border-color: var(--primary); }

.reel-video { width: 100%; max-height: 520px; display: block; background: #000; }

.reel-info { padding: 16px; }
.reel-title { font-size: 0.95rem; font-weight: 600; }
.reel-meta { font-size: 0.8rem; color: var(--text-2); margin-top: 4px; }
.reel-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ===== FILES TABLE ===== */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg-3); }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
th { color: var(--text-2); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: rgba(102,126,234,.05); }
tbody tr:last-child td { border-bottom: none; }

.file-icon { font-size: 1.3rem; }
.file-name-cell { display: flex; align-items: center; gap: 10px; }
.file-name-text { max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== UPLOAD ===== */
.upload-zone {
    border: 2px dashed var(--border-2);
    border-radius: var(--radius);
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-2);
    position: relative;
}
.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(102,126,234,.05);
}
.upload-zone-icon { font-size: 3rem; color: var(--primary); margin-bottom: 16px; }
.upload-zone-text { color: var(--text-2); margin-bottom: 8px; }
.upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.file-list-preview { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.file-list-item {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-3); padding: 10px 14px; border-radius: var(--radius-sm);
    font-size: 0.85rem;
}
.file-list-item-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-list-item-size { color: var(--text-2); font-size: 0.8rem; }

.progress-container { margin-top: 16px; }
.progress-bar-wrap { height: 8px; background: var(--bg-3); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 4px; transition: width .1s linear; }
.progress-info { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-2); margin-top: 6px; }

/* ===== FILTERS ===== */
.filters { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ===== FAVORITE BUTTON ===== */
.fav-btn { background: none; border: none; cursor: pointer; padding: 4px; font-size: 1rem; transition: transform var(--transition); }
.fav-btn:hover { transform: scale(1.3); }
.fav-btn.active { color: var(--danger); }
.fav-btn:not(.active) { color: var(--text-3); }

/* ===== ALERTS ===== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.alert-success { background: rgba(67,233,123,.1); border-color: rgba(67,233,123,.3); color: #43e97b; }
.alert-error   { background: rgba(245,87,108,.1); border-color: rgba(245,87,108,.3); color: #f5576c; }
.alert-warning { background: rgba(249,168,37,.1); border-color: rgba(249,168,37,.3); color: #f9a825; }
.alert-info    { background: rgba(102,126,234,.1); border-color: rgba(102,126,234,.3); color: var(--primary); }
.alert-close   { margin-left: auto; background: none; border: none; cursor: pointer; color: inherit; font-size: 1rem; opacity: .7; }
.alert-close:hover { opacity: 1; }

/* ===== MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow);
    animation: modal-in .2s ease;
}
@keyframes modal-in { from { opacity:0; transform:scale(.95); } to { opacity:1; transform:scale(1); } }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-2); font-size: 1.2rem; transition: color var(--transition); padding: 4px; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.lightbox-img { max-width: 100%; max-height: 70vh; object-fit: contain; display: block; margin: 0 auto; border-radius: var(--radius-sm); }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: var(--bg-2);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    min-width: 260px;
    display: flex; align-items: center; gap: 12px;
    box-shadow: var(--shadow);
    animation: toast-in .3s ease;
    font-size: 0.875rem;
}
@keyframes toast-in { from { opacity:0; transform:translateX(100%); } to { opacity:1; transform:translateX(0); } }
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--primary); }

/* ===== AUTH / INSTALL PAGES ===== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(ellipse at top left, rgba(102,126,234,.15), transparent 50%),
                radial-gradient(ellipse at bottom right, rgba(118,75,162,.1), transparent 50%);
}
.auth-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow);
}
.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}
.auth-logo .logo-icon-large {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border-radius: var(--radius);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.8rem; color: #fff; margin-bottom: 12px;
}
.auth-logo h1 {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.auth-logo p { color: var(--text-2); font-size: 0.875rem; margin-top: 4px; }

/* ===== INSTALL STEPS ===== */
.install-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
}
.step-dot {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700;
    border: 2px solid var(--border-2);
    color: var(--text-2);
}
.step-dot.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.step-dot.done { border-color: var(--success); background: rgba(67,233,123,.15); color: var(--success); }
.step-line { flex: 1; max-width: 40px; height: 2px; background: var(--border-2); }
.step-line.done { background: var(--success); }

/* ===== OTP INPUT ===== */
.otp-input-group { display: flex; gap: 10px; justify-content: center; margin: 20px 0; }
.otp-digit {
    width: 54px; height: 60px;
    background: var(--bg-3); border: 2px solid var(--border-2);
    border-radius: var(--radius-sm);
    color: var(--text); font-size: 1.5rem; font-weight: 700;
    text-align: center; outline: none;
    transition: border-color var(--transition);
}
.otp-digit:focus { border-color: var(--primary); }

/* ===== SEARCH ===== */
.search-wrap { position: relative; }
.search-wrap input { padding-left: 38px; }
.search-wrap i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-2); }
.empty-state i { font-size: 3.5rem; margin-bottom: 16px; opacity: .3; display: block; }
.empty-state p { font-size: 0.9rem; }

/* ===== BADGE ===== */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 9px; border-radius: 20px; font-size: 0.73rem; font-weight: 600;
}
.badge-primary { background: rgba(102,126,234,.2); color: var(--primary); }
.badge-success { background: rgba(67,233,123,.2); color: var(--success); }
.badge-warning { background: rgba(249,168,37,.2); color: var(--warning); }
.badge-danger  { background: rgba(245,87,108,.2); color: var(--danger); }

/* ===== SETTINGS ===== */
.settings-section { margin-bottom: 28px; }
.settings-section-title {
    font-size: 0.8rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .8px;
    color: var(--text-3); margin-bottom: 16px;
    padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 20px; }

/* ===== LAST LOGIN ===== */
.last-login-card { display: flex; align-items: center; gap: 16px; }
.last-login-icon { font-size: 1.5rem; color: var(--primary); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); width: var(--sidebar-w); }
    .main-content { margin-left: 0; }
    .hamburger { display: flex; }
    .page-body { padding: 20px 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
    .auth-card { padding: 28px 20px; }
    .modal { margin: 10px; }
    .topbar { padding: 0 16px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .otp-digit { width: 42px; height: 52px; font-size: 1.2rem; }
    .otp-input-group { gap: 6px; }
    .gallery-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== SIDEBAR OVERLAY ===== */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 199;
}
.sidebar-overlay.active { display: block; }

/* ===== MISC ===== */
.text-gradient {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-2); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.w-full { width: 100%; }
.cursor-pointer { cursor: pointer; }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }
