:root {
  --primary: #2563eb;
  --bg: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --card-bg: #ffffff;
  --radius: 10px;
}

* { box-sizing: border-box; }

html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* Top nav */
.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  z-index: 1030; /* above modals and other content */
  box-shadow: 0 2px 8px rgba(2,6,23,0.04);
}
.top-nav-inner {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 16px;
}
.top-nav .brand-link { font-weight: 600; color: var(--primary); font-size: 1.125rem; text-decoration: none; }
.top-nav .nav-links { display: flex; gap: 14px; align-items: center; }
.top-nav .nav-link { color: var(--muted); font-weight: 500; padding: 8px 12px; border-radius: 8px; }
.top-nav .nav-link:hover { color: var(--primary); background: rgba(37,99,235,0.06); }
.top-nav .auth { display: flex; gap: 8px; align-items: center; }
.top-nav .username { color: var(--muted); padding-right: 8px; }
.btn.btn-ghost { background: transparent; border: none; color: var(--primary); padding: 8px 12px; }

/* Main centered content */
.main-container { padding-top: 84px; max-width: 1100px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.content { padding: 24px 0 120px 0; }

/* Cards and accents */
.card { background: var(--card-bg); border-radius: var(--radius); padding: 18px; box-shadow: 0 6px 16px rgba(2,6,23,0.04); margin-bottom: 18px; }
.muted { color: var(--muted); }

/* Buttons */
.btn { display: inline-block; font-weight: 600; color: #fff; background: var(--primary); padding: 10px 16px; border-radius: 8px; border: none; text-decoration: none; cursor: pointer; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: #ffffff; color: var(--primary); border: 1px solid rgba(37,99,235,0.12); }
.btn-sm { padding: 6px 10px; font-size: 0.9rem; border-radius: 6px; }

/* Outline Buttons */
.btn-outline-primary { background: transparent; color: var(--primary); border: 1px solid rgba(37,99,235,0.12); }
.btn-outline-danger { background: transparent; color: #dc2626; border: 1px solid rgba(220,38,38,0.12); }
.btn-outline-secondary { background: transparent; color: var(--muted); border: 1px solid rgba(107,114,128,0.06); }

/* Small outline variants */
.btn-outline-primary.btn-sm, .btn-outline-danger.btn-sm, .btn-outline-secondary.btn-sm { padding: 4px 8px; font-size: 0.85rem; border-radius: 6px; }

/* Folder-style cards */
.folder-button, .folder-btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 160px; height: 120px; border-radius: 10px; padding: 12px; background: linear-gradient(180deg,#ffffff,#f6f8ff); border: 1px solid rgba(15,23,42,0.06); color: var(--text); cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; }
.folder-button:hover { transform: translateY(-6px); box-shadow: 0 12px 30px rgba(16,24,40,0.06); }
.folder-button.active { border-color: var(--primary); box-shadow: 0 16px 28px rgba(37,99,235,0.08); background: linear-gradient(180deg, #f3f7ff, #f6fbff); }
.folder-button .icon { font-size: 34px; color: var(--primary); }
.folder-button .name { font-weight: 600; }

/* Subtype separation */
.section-title { display: block; margin-bottom: 8px; font-weight: 700; }

/* Drag drop upload box */
.upload-box { min-height: 160px; border-radius: 12px; border: 2px dashed rgba(15,23,42,0.06); display: flex; align-items: center; justify-content: center; background: linear-gradient(180deg,#ffffff,#fbfdff); }
.upload-box.drag-over { border-color: var(--primary); background: rgba(37,99,235,0.03); }
.upload-box .drop-text { color: var(--muted); text-align: center; }

.file-list { margin-top: 12px; }
.file-list-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-radius: 8px; background: #f8fafb; margin-bottom: 8px; }

/* Table styles */
.table { width: 100%; border-collapse: collapse; }
.table thead th { text-align: left; color: var(--muted); padding: 8px 12px; font-weight: 600; }
.table tbody td { padding: 12px; border-top: 1px solid rgba(15,23,42,0.04); }
.badge { display: inline-block; padding: 6px 10px; border-radius: 999px; font-weight: 600; font-size: 0.9rem; }
.badge.active { background: #def7ec; color: #065f46; }
.badge.inactive { background: #ffefe8; color: #7f1d1d; }

/* Auth forms */
.auth-card { width: 420px; margin: 48px auto; background: var(--card-bg); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(2,6,23,0.06); padding: 22px; }
.form-label { font-weight: 600; margin-bottom: 6px; display: block; }
.form-control { width: 100%; padding: 8px 10px; border: 1px solid rgba(15,23,42,0.06); border-radius: 8px; background: transparent; }

/* Footer */
footer { padding: 24px 0; text-align: center; color: var(--muted); }

/* Small utilities */
.text-muted { color: var(--muted); }

html, body {
    height: 100%;
    margin: 0;
}

.app-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-content {
    flex: 1;
    padding: 24px;
}

/* Footer */
.app-footer {
    border-top: 1px solid #e5e7eb;
    padding: 12px 16px;
    text-align: center;
    background-color: #fff;
    font-size: 14px;
    color: #6b7280;
}

/* Responsive adjustments for mobile screens */
@media (max-width: 768px) {
  .top-nav-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
  }
  /* Center brand and keep toggler to the right on small screens */
  .navbar-brand { order: 1; width: 100%; text-align: center; }
  .navbar-toggler { order: 2; margin-left: auto; }
  .top-nav .brand-link { font-size: 1rem; }
  .top-nav .nav-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
  .top-nav .nav-links { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .top-nav .nav-item { padding: 6px 8px; font-size: 0.95rem; border-radius: 6px; }
  .top-nav .auth { justify-self: end; margin-top: 6px; }

  /* Make main container full width with smaller padding */
  .main-container { padding-top: 72px; max-width: 100%; margin: 0; padding-left: 12px; padding-right: 12px; }
  .content { padding: 18px 0 80px 0; }

  /* Auth/card forms to be full width */
  .auth-card { width: 100%; max-width: 420px; margin: 20px auto; padding: 18px; }
  .form-label { font-size: 0.95rem; }
  .form-control { padding: 10px; }

  /* Folder buttons and other fixed-width elements should shrink */
  .folder-button, .folder-btn { width: 120px; height: 110px; }

  /* Tables and lists: enable horizontal scrolling if needed */
  .table-responsive { overflow-x: auto; }
  .table { min-width: 600px; }

  /* Reduce card padding for small screens and center */
  .card { padding: 14px; max-width: 720px; margin-left: auto; margin-right: auto; }
}

/* Extra small screens */
@media (max-width: 420px) {
  .top-nav-inner { padding: 8px 10px; }
  .top-nav .brand-link { font-size: 0.95rem; }
  .top-nav .nav-item { font-size: 0.9rem; padding: 6px 8px; }
  .auth-card { padding: 14px; margin: 12px; }
  .btn { width: 100%; text-align: center; }
}
