/* frontend/public/css/global.css
   GradeEssays Design System
   Primary: Orange #f97316 | Dark: #111827 | Accent: #1e40af
*/

:root {
  --orange:        #f97316;
  --orange-hover:  #ea580c;
  --orange-light:  #fff7ed;
  --orange-border: #fed7aa;
  --dark:          #111827;
  --dark-2:        #1f2937;
  --dark-3:        #374151;
  --gray:          #6b7280;
  --gray-light:    #e5e7eb;
  --gray-bg:       #f9fafb;
  --white:         #ffffff;
  --green:         #10b981;
  --green-light:   #ecfdf5;
  --red:           #ef4444;
  --red-light:     #fef2f2;
  --blue:          #3b82f6;
  --blue-light:    #eff6ff;
  --amber:         #f59e0b;
  --amber-light:   #fffbeb;
  --radius:        10px;
  --radius-lg:     16px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow:        0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.12);
  --transition:    all .2s ease;
  --sidebar-w:     260px;
}

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

html { scroll-behavior: smooth; }

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

a { color: var(--orange); text-decoration: none; }
a:hover { text-decoration: underline; }

h1,h2,h3,h4 { line-height: 1.3; color: var(--dark); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius);
  font-size: .95rem; font-weight: 600; cursor: pointer;
  border: none; transition: var(--transition); text-decoration: none;
  white-space: nowrap;
}
.btn-primary   { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-hover); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(249,115,22,.35); text-decoration: none; }
.btn-secondary { background: var(--gray-bg); color: var(--dark); border: 1px solid var(--gray-light); }
.btn-secondary:hover { background: var(--gray-light); text-decoration: none; }
.btn-dark      { background: var(--dark); color: #fff; }
.btn-dark:hover{ background: var(--dark-2); text-decoration: none; }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; text-decoration: none; }
.btn-success   { background: var(--green); color: #fff; }
.btn-success:hover { background: #059669; text-decoration: none; }
.btn-sm  { padding: 6px 14px; font-size: .85rem; }
.btn-lg  { padding: 14px 28px; font-size: 1.05rem; }
.btn-full{ width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none !important; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 24px;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-light);
}
.card-header h2, .card-header h3 { margin: 0; font-size: 1.1rem; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; margin-bottom: 6px;
  font-weight: 500; font-size: .9rem; color: var(--dark-3);
}
.required { color: var(--red); }
input, select, textarea {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--gray-light); border-radius: var(--radius);
  font-size: .95rem; font-family: inherit;
  background: var(--white); color: var(--dark);
  transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(249,115,22,.12);
}
textarea { resize: vertical; min-height: 100px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media(max-width:640px){ .form-row { grid-template-columns: 1fr; } }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: 12px 18px; border-radius: var(--radius);
  font-size: .9rem; margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert-error   { background: var(--red-light);   color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: var(--green-light);  color: #065f46; border: 1px solid #a7f3d0; }
.alert-info    { background: var(--blue-light);   color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: var(--amber-light);  color: #92400e; border: 1px solid #fde68a; }

/* ── Status badges ───────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
}
.badge-pending    { background: #f3f4f6;  color: #6b7280; }
.badge-bidding    { background: #eff6ff;  color: #1d4ed8; }
.badge-in_progress{ background: #fff7ed;  color: #c2410c; }
.badge-submitted  { background: #fdf4ff;  color: #7e22ce; }
.badge-revision   { background: #fffbeb;  color: #b45309; }
.badge-completed  { background: #ecfdf5;  color: #065f46; }
.badge-cancelled  { background: #fef2f2;  color: #991b1b; }
.badge-disputed   { background: #fef2f2;  color: #991b1b; }
.badge-paid       { background: #ecfdf5;  color: #065f46; }
.badge-unpaid     { background: #fef2f2;  color: #991b1b; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
  background: var(--dark); color: #fff;
  padding: 12px 16px; text-align: left;
  font-size: .8rem; text-transform: uppercase; letter-spacing: .5px;
}
tbody tr { border-bottom: 1px solid var(--gray-light); }
tbody tr:hover { background: var(--gray-bg); }
tbody td { padding: 12px 16px; vertical-align: middle; color: var(--dark-3); }
tbody tr:last-child { border-bottom: none; }

/* ── Dashboard layout ────────────────────────────────────── */
.dash-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--dark);
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto; display: flex; flex-direction: column;
}
.sidebar-brand {
  padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand a {
  color: var(--orange); font-size: 1.5rem; font-weight: 700; text-decoration: none;
}
.sidebar-brand small { display: block; color: rgba(255,255,255,.4); font-size: .75rem; margin-top: 2px; }
.sidebar-nav { padding: 16px 0; flex: 1; }
.nav-section { padding: 8px 20px 4px; color: rgba(255,255,255,.3); font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; color: rgba(255,255,255,.65);
  font-size: .9rem; transition: var(--transition); text-decoration: none;
}
.nav-link:hover    { color: #fff; background: rgba(255,255,255,.06); text-decoration: none; }
.nav-link.active   { color: var(--orange); background: rgba(249,115,22,.1); border-right: 3px solid var(--orange); }
.nav-link svg      { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer    { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); }

.main-content { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: var(--white); border-bottom: 1px solid var(--gray-light);
  padding: 14px 28px; display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-size: 1.1rem; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.page-body { padding: 28px; flex: 1; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.stat-card .stat-label { font-size: .8rem; color: var(--gray); text-transform: uppercase; letter-spacing: .5px; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--dark); margin: 6px 0; }
.stat-card .stat-sub   { font-size: .8rem; color: var(--gray); }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.stat-icon-orange { background: var(--orange-light); color: var(--orange); }
.stat-icon-green  { background: var(--green-light);  color: var(--green); }
.stat-icon-blue   { background: var(--blue-light);   color: var(--blue); }
.stat-icon-amber  { background: var(--amber-light);  color: var(--amber); }

/* Notification bell */
.notif-bell { position: relative; cursor: pointer; color: var(--dark-3); }
.notif-badge { position: absolute; top: -6px; right: -6px; background: var(--red); color: #fff; font-size: .65rem; min-width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* Avatar */
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--orange); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; flex-shrink: 0; }

/* Mobile sidebar toggle */
.menu-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--dark); }
@media(max-width:900px){
  .dash-layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -100%; top: 0; z-index: 999; width: var(--sidebar-w); transition: left .3s ease; }
  .sidebar.open { left: 0; }
  .menu-toggle { display: block; }
  .page-body { padding: 16px; }
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 16px; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--white); border-radius: var(--radius-lg); padding: 28px; max-width: 520px; width: 100%; box-shadow: var(--shadow-lg); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 1.1rem; margin: 0; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--gray); line-height: 1; }

/* ── Chat ────────────────────────────────────────────────── */
.chat-wrap { display: flex; flex-direction: column; height: 420px; border: 1.5px solid var(--gray-light); border-radius: var(--radius); overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-bubble { max-width: 72%; }
.chat-bubble.mine { align-self: flex-end; }
.chat-bubble.theirs { align-self: flex-start; }
.bubble-text {
  padding: 10px 14px; border-radius: 18px; font-size: .9rem; line-height: 1.5;
}
.mine .bubble-text   { background: var(--orange); color: #fff; border-bottom-right-radius: 4px; }
.theirs .bubble-text { background: var(--gray-bg); color: var(--dark); border: 1px solid var(--gray-light); border-bottom-left-radius: 4px; }
.bubble-meta { font-size: .72rem; color: var(--gray); margin-top: 3px; }
.mine .bubble-meta { text-align: right; }
.chat-input-area { border-top: 1px solid var(--gray-light); padding: 12px; display: flex; gap: 8px; align-items: flex-end; background: var(--white); }
.chat-input-area textarea { flex: 1; border-radius: 20px; padding: 8px 14px; min-height: 40px; max-height: 100px; resize: none; }
.typing-indicator { font-size: .8rem; color: var(--gray); padding: 0 16px 8px; font-style: italic; min-height: 20px; }

/* ── File upload zone ────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--gray-light); border-radius: var(--radius);
  padding: 24px; text-align: center; cursor: pointer;
  transition: var(--transition); color: var(--gray);
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--orange); background: var(--orange-light); color: var(--orange); }
.file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.file-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--gray-bg); border-radius: 6px; font-size: .85rem; }
.file-item button { background: none; border: none; color: var(--red); cursor: pointer; font-size: 1.1rem; line-height: 1; }

/* ── Loading ─────────────────────────────────────────────── */
.spinner { width: 20px; height: 20px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.spinner.dark { border-color: rgba(0,0,0,.1); border-top-color: var(--orange); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state { text-align: center; padding: 48px; color: var(--gray); }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 24px; color: var(--gray); }
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: .3; }
.empty-state h3 { color: var(--dark-3); margin-bottom: 8px; }

/* ── Misc ────────────────────────────────────────────────── */
.text-orange { color: var(--orange); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-gray   { color: var(--gray); }
.text-sm     { font-size: .85rem; }
.text-xs     { font-size: .75rem; }
.fw-600      { font-weight: 600; }
.fw-700      { font-weight: 700; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media(max-width:640px){ .grid-2 { grid-template-columns: 1fr; } }
