/* CloudVault — Main Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary:      #6366f1;
  --primary-dark: #4f46e5;
  --primary-light:#e0e7ff;
  --success:      #22c55e;
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --info:         #3b82f6;
  --dark:         #0f172a;
  --dark2:        #1e293b;
  --dark3:        #334155;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --border:       #e2e8f0;
  --bg:           #f8fafc;
  --bg2:          #f1f5f9;
  --white:        #ffffff;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
  --shadow:       0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:    0 10px 40px rgba(0,0,0,.18);
  --radius:       12px;
  --radius-sm:    8px;
  --sidebar-w:    260px;
  --header-h:     64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--dark2);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform .25s ease;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px;
  color: #fff;
  font-size: 1.2rem; font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-section {
  padding: 8px 18px 4px;
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: #475569; margin-top: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px;
  color: #94a3b8;
  font-size: .875rem; font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
  cursor: pointer;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav-item.active { background: rgba(99,102,241,.15); color: #a5b4fc; border-left-color: var(--primary); }
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 1rem; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--primary); color: #fff;
  font-size: .68rem; padding: 2px 7px;
  border-radius: 20px; min-width: 20px; text-align: center;
}
.sidebar-quota {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .9rem;
  flex-shrink: 0; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info strong { display: block; font-size: .83rem; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info small { color: #64748b; font-size: .73rem; }

/* ── Main Content ── */
.main-content { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }

/* ── Topbar ── */
.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 14px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 1.05rem; font-weight: 600; color: var(--dark); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-bar {
  display: flex; align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 7px 16px; gap: 8px;
  width: 260px; transition: all .2s;
}
.search-bar:focus-within { border-color: var(--primary); background: #fff; }
.search-bar input { border: none; background: transparent; outline: none; flex: 1; font-size: .875rem; color: var(--text); min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.icon-btn {
  width: 38px; height: 38px;
  border: none; background: var(--bg2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem; color: var(--text-muted);
  transition: all .15s; position: relative; text-decoration: none;
}
.icon-btn:hover { background: var(--primary-light); color: var(--primary); }
.notification-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger); border-radius: 50%;
  border: 2px solid var(--white);
}
.mobile-toggle {
  display: none;
  background: none; border: none;
  font-size: 1.3rem; cursor: pointer;
  color: var(--text); padding: 4px;
}

/* ── Page Content ── */
.page-content { flex: 1; padding: 24px; }
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 1.35rem; font-weight: 700; color: var(--dark); }
.page-header p { color: var(--text-muted); font-size: .875rem; margin-top: 2px; }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2, .card-header h3 { font-size: .95rem; font-weight: 600; }
.card-body { padding: 20px; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px 16px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: box-shadow .2s, transform .2s;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; flex-shrink: 0;
}
.stat-icon.blue   { background: #dbeafe; }
.stat-icon.green  { background: #dcfce7; }
.stat-icon.purple { background: #ede9fe; }
.stat-icon.orange { background: #ffedd5; }
.stat-icon.red    { background: #fee2e2; }
.stat-icon.gray   { background: var(--bg2); }
.stat-value { font-size: 1.45rem; font-weight: 700; color: var(--dark); line-height: 1.1; }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: 3px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer; transition: all .15s;
  white-space: nowrap; text-decoration: none;
  font-family: inherit;
}
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-secondary { background: var(--bg2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #e2e8f0; color: var(--dark); }
.btn-danger  { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-sm { padding: 5px 12px; font-size: .8rem; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: .95rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .875rem; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.form-label.required::after { content: ' *'; color: var(--danger); }
.form-control {
  width: 100%; padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem; color: var(--text);
  background: var(--white);
  transition: border-color .2s, box-shadow .2s;
  outline: none; font-family: inherit;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.form-control:disabled { background: var(--bg2); cursor: not-allowed; color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
}
.form-hint  { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: .8rem; color: var(--danger); margin-top: 4px; }
.input-icon-wrap { position: relative; }
.input-icon-wrap .form-control { padding-left: 40px; }
.input-icon-wrap .input-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .9rem; pointer-events: none; }

/* ── Alerts ── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  border: 1px solid; font-size: .875rem;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 16px;
}
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-error   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table thead th {
  background: var(--bg2); padding: 10px 14px;
  text-align: left; font-weight: 600; color: var(--text-muted);
  font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table td { padding: 11px 14px; color: var(--text); vertical-align: middle; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: .72rem; font-weight: 600;
}
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-green  { background: #dcfce7; color: #166534; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-gray   { background: var(--bg2); color: var(--text-muted); }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-orange { background: #ffedd5; color: #9a3412; }

/* ── Upload Zone ── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 48px 24px; text-align: center; cursor: pointer;
  transition: all .2s; background: var(--bg2);
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--primary); background: var(--primary-light); }
.upload-zone .upload-icon { font-size: 2.5rem; margin-bottom: 12px; }
.upload-zone h3 { font-size: 1rem; font-weight: 600; color: var(--dark); }
.upload-zone p  { font-size: .85rem; color: var(--text-muted); margin-top: 6px; }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 500;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white); border-radius: var(--radius);
  width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
  max-height: 90vh; overflow-y: auto;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 18px 22px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--white); z-index: 1;
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); line-height: 1; padding: 2px; }
.modal-close:hover { color: var(--dark); }

/* ── Progress ── */
.progress-bar { height: 6px; background: var(--bg2); border-radius: 20px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); border-radius: 20px; transition: width .3s; }

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: .84rem; color: var(--text-muted);
  margin-bottom: 16px; flex-wrap: wrap;
}
.breadcrumb a { color: var(--primary); }
.breadcrumb .sep { color: var(--border); }
.breadcrumb .current { color: var(--dark); font-weight: 500; }

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh;
  display: flex;
}
.login-left {
  flex: 1;
  background: linear-gradient(145deg, #0f172a 0%, #1e293b 60%, #312e81 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 48px 40px;
}
.login-left-content { max-width: 420px; color: #fff; }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 40px; }
.login-brand .logo-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; flex-shrink: 0;
}
.login-brand span { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.login-left h2 { font-size: 2.1rem; font-weight: 800; line-height: 1.2; margin-bottom: 14px; }
.login-left p  { color: #94a3b8; font-size: .95rem; line-height: 1.7; margin-bottom: 32px; }
.login-features { display: flex; flex-direction: column; gap: 12px; }
.login-feature {
  display: flex; align-items: center; gap: 12px;
  color: #cbd5e1; font-size: .9rem;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.login-feature-icon { font-size: 1.1rem; flex-shrink: 0; }

.login-right {
  flex: 0 0 480px;
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  padding: 48px 40px;
  box-shadow: -4px 0 40px rgba(0,0,0,.08);
}
.login-box { width: 100%; max-width: 380px; }
.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 32px;
}
.login-logo .logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}
.login-logo span { font-size: 1.4rem; font-weight: 700; color: var(--dark); }
.login-box h2 { font-size: 1.5rem; font-weight: 700; color: var(--dark); margin-bottom: 6px; }
.login-box .subtitle { color: var(--text-muted); font-size: .875rem; margin-bottom: 28px; }
.login-links { margin-top: 20px; display: flex; justify-content: space-between; font-size: .8rem; flex-wrap: wrap; gap: 8px; }
.login-footer { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); text-align: center; font-size: .78rem; color: var(--text-muted); }
.login-footer a { margin: 0 6px; }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--dark); margin-bottom: 6px; }

/* ── Toast ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--dark2); color: #fff;
  padding: 13px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: .875rem;
  display: flex; align-items: center; gap: 10px;
  min-width: 260px; max-width: 380px;
  animation: toastIn .25s ease;
  border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── Misc ── */
.separator { height: 1px; background: var(--border); margin: 16px 0; }
.text-muted  { color: var(--text-muted) !important; }
.text-danger { color: var(--danger) !important; }
.text-success{ color: var(--success) !important; }
.text-primary{ color: var(--primary) !important; }
.d-flex  { display: flex; }
.gap-2   { gap: 8px; }
.gap-3   { gap: 12px; }
.flex-1  { flex: 1; }
.mt-1    { margin-top: 4px; }
.mt-2    { margin-top: 8px; }
.mt-3    { margin-top: 16px; }
.mb-2    { margin-bottom: 8px; }
.mb-3    { margin-bottom: 16px; }
.mb-4    { margin-bottom: 24px; }
.w-100   { width: 100%; }
code { background: var(--bg2); padding: 2px 7px; border-radius: 5px; font-size: .82rem; font-family: monospace; }

/* ── Upload file list ── */
.upload-file-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg2); border-radius: var(--radius-sm);
  font-size: .84rem;
}
.upload-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  .login-left { display: none; }
  .login-right { flex: 1; box-shadow: none; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-content { margin-left: 0; }
  .mobile-toggle { display: flex; }
  .search-bar { display: none; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; gap: 10px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .login-right { padding: 32px 20px; }
  .login-box { max-width: 100%; }
  /* Stacked grids on mobile */
  [style*="grid-template-columns: 220px"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns: 280px"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns: 1fr 340px"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns: 1fr 280px"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
  .modal { margin: 0; border-radius: var(--radius) var(--radius) 0 0; max-width: 100%; }
  .modal-overlay.open { align-items: flex-end; padding: 0; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .topbar-actions .btn span { display: none; }
}

/* ── Overlay for mobile sidebar ── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 150;
}
.sidebar-overlay.show { display: block; }

/* ── Print ── */
@media print {
  .sidebar, .topbar, .btn, .modal-overlay, #toast-container { display: none !important; }
  .main-content { margin: 0 !important; }
}
