/* ============================================
   KCR Submission Manager — Global Styles
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary: #0f172a;
  --accent: #f59e0b;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --info: #0ea5e9;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --transition: 0.2s ease;
  --sidebar-width: 260px;
  --header-height: 64px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

/* --- Typography --- */
h1 { font-size: 1.875rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.5rem;   font-weight: 700; line-height: 1.3; }
h3 { font-size: 1.25rem;  font-weight: 600; line-height: 1.4; }
h4 { font-size: 1.1rem;   font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 0.875rem; }

/* --- Layout: App Shell --- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--secondary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-brand .logo {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem;
}
.sidebar-brand h2 { font-size: 1.1rem; font-weight: 700; color: #fff; }
.sidebar-brand small { display: block; font-size: .7rem; color: var(--text-light); font-weight: 400; }

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1.5rem;
  color: rgba(255,255,255,.65);
  font-size: .9rem; font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: #fff;
  background: rgba(255,255,255,.07);
  border-left-color: var(--primary);
}
.sidebar-nav a .icon { width: 20px; text-align: center; font-size: 1rem; }
.sidebar-nav .nav-section {
  padding: .5rem 1.5rem .3rem;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-light);
  margin-top: .5rem;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; gap: .75rem;
}
.sidebar-footer .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .85rem; color: #fff;
}
.sidebar-footer .user-info { flex: 1; }
.sidebar-footer .user-info .name { font-size: .85rem; font-weight: 600; color: #fff; }
.sidebar-footer .user-info .role { font-size: .7rem; color: var(--text-light); }

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

/* --- Top Header Bar --- */
.top-bar {
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.top-bar .page-title { font-size: 1.15rem; font-weight: 700; }
.top-bar-actions { display: flex; align-items: center; gap: 1rem; }
.hamburger {
  display: none;
  background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text);
}

/* --- Page Content --- */
.page-content {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  width: 100%;
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 1.5rem; }
.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* --- Stat Cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.stat-card .stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-card .stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-card .stat-icon.green  { background: #dcfce7; color: var(--success); }
.stat-card .stat-icon.yellow { background: #fef3c7; color: var(--warning); }
.stat-card .stat-icon.red    { background: #fee2e2; color: var(--danger); }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1.25rem;
  font-size: .875rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  line-height: 1.4;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-alt); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { padding: .4rem .85rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }
.btn-icon {
  width: 36px; height: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-muted);
}
.btn-icon:hover { background: var(--surface-alt); color: var(--text); }
.btn-group { display: flex; gap: .5rem; }

/* --- Forms --- */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .4rem;
}
.form-label .required { color: var(--danger); }
.form-control {
  width: 100%;
  padding: .65rem .9rem;
  font-size: .9rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .3rem; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* --- File Upload --- */
.file-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface-alt);
}
.file-upload-zone:hover,
.file-upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.file-upload-zone .upload-icon { font-size: 2.5rem; color: var(--text-light); margin-bottom: .75rem; }
.file-upload-zone p { font-size: .9rem; color: var(--text-muted); }
.file-upload-zone .browse-link { color: var(--primary); font-weight: 600; cursor: pointer; }
.file-list { margin-top: 1rem; }
.file-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .5rem;
  font-size: .85rem;
}
.file-item .file-name { flex: 1; font-weight: 500; }
.file-item .file-size { color: var(--text-muted); font-size: .78rem; }
.file-item .file-remove { color: var(--danger); cursor: pointer; background: none; border: none; font-size: 1rem; }

/* --- Tables --- */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  text-align: left;
  padding: .85rem 1rem;
  font-weight: 600;
  color: var(--text-muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--border);
  background: var(--surface-alt);
  white-space: nowrap;
}
tbody td {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--surface-alt); }

/* --- Badges / Status --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .25rem .7rem;
  font-size: .75rem;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-accepted { background: #dcfce7; color: #166534; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-review   { background: var(--primary-light); color: var(--primary-dark); }
.badge-info     { background: #e0f2fe; color: #075985; }

/* --- Search & Filters --- */
.filters-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.search-input {
  position: relative;
  flex: 1;
  min-width: 220px;
}
.search-input input {
  width: 100%;
  padding: .6rem .9rem .6rem 2.4rem;
  font-size: .875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: inherit;
  transition: border-color var(--transition);
}
.search-input input:focus { outline: none; border-color: var(--primary); }
.search-input .search-icon {
  position: absolute;
  left: .8rem; top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: .9rem;
}
.filter-select {
  padding: .6rem .9rem;
  font-size: .875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: inherit;
  cursor: pointer;
  color: var(--text);
}

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
}
.tab {
  padding: .75rem 1.25rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* --- Messages / Chat --- */
.message-list { display: flex; flex-direction: column; gap: .75rem; }
.message-item {
  display: flex;
  gap: .75rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--surface-alt);
}
.message-item.own { background: var(--primary-light); }
.message-item .msg-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: .8rem;
  flex-shrink: 0;
}
.message-item .msg-content { flex: 1; }
.message-item .msg-header {
  display: flex; align-items: center; gap: .5rem;
  margin-bottom: .3rem;
}
.message-item .msg-author { font-weight: 600; font-size: .85rem; }
.message-item .msg-time { font-size: .75rem; color: var(--text-light); }
.message-item .msg-body { font-size: .875rem; color: var(--text); line-height: 1.5; }

.message-compose {
  display: flex;
  gap: .75rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.message-compose input {
  flex: 1;
  padding: .65rem .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .875rem;
}
.message-compose input:focus { outline: none; border-color: var(--primary); }

/* --- Document Viewer --- */
.doc-viewer {
  display: flex;
  gap: 1.5rem;
  height: calc(100vh - var(--header-height) - 6rem);
  min-height: 500px;
}
.doc-preview {
  flex: 2;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.doc-preview-header {
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-alt);
}
.doc-preview-body {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  font-size: .95rem;
  line-height: 1.8;
}
.doc-sidebar {
  flex: 1;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* --- Rating --- */
.rating { display: flex; gap: .25rem; }
.rating .star {
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--border);
  transition: color var(--transition);
}
.rating .star.filled,
.rating .star:hover { color: var(--accent); }

/* --- Progress Bar --- */
.progress-bar {
  height: 8px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  border-radius: 999px;
  transition: width .5s ease;
}
.progress-bar .fill.blue   { background: var(--primary); }
.progress-bar .fill.green  { background: var(--success); }
.progress-bar .fill.yellow { background: var(--warning); }
.progress-bar .fill.red    { background: var(--danger); }

/* --- Notifications Dropdown --- */
.notification-bell { position: relative; }
.notification-bell .badge-count {
  position: absolute;
  top: -4px; right: -4px;
  width: 18px; height: 18px;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* --- Modal Overlay --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: .5rem;
}
.modal-close {
  background: none; border: none;
  font-size: 1.3rem; cursor: pointer; color: var(--text-muted);
}

/* --- Checkbox toggle --- */
.toggle-switch {
  position: relative;
  width: 44px; height: 24px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch .slider {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background var(--transition);
}
.toggle-switch .slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle-switch input:checked + .slider { background: var(--primary); }
.toggle-switch input:checked + .slider::before { transform: translateX(20px); }

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { margin-bottom: .5rem; color: var(--text); }

/* --- Auth Pages (Login/Register) --- */
.auth-page {
  display: flex;
  min-height: 100vh;
}
.auth-hero {
  flex: 1;
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary-dark) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}
.auth-hero::before {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  top: -100px; right: -100px;
}
.auth-hero::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,.03);
  bottom: -80px; left: -80px;
}
.auth-hero h1 { font-size: 2.5rem; margin-bottom: .75rem; position: relative; z-index: 1; }
.auth-hero p { font-size: 1.1rem; opacity: .8; max-width: 400px; text-align: center; position: relative; z-index: 1; }

.auth-form-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.auth-form {
  width: 100%;
  max-width: 420px;
}
.auth-form h2 { margin-bottom: .5rem; }
.auth-form .subtitle { color: var(--text-muted); margin-bottom: 2rem; }
.auth-form .auth-footer { margin-top: 1.5rem; text-align: center; font-size: .875rem; }

/* --- Responsive --- */
@media (max-width: 1024px) {
  .doc-viewer { flex-direction: column; height: auto; }
  .doc-sidebar { max-width: none; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .top-bar { padding: 0 1rem; }
  .page-content { padding: 1.25rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .search-input { min-width: auto; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
