/* public/css/main.css */
/* ЮЦДП Auction Scheduler — Forest institutional design */

:root {
  /* Forest palette */
  --forest-900: #1a2e1a;
  --forest-800: #243524;
  --forest-700: #2e4a2e;
  --forest-600: #3a5c3a;
  --forest-500: #4a7a4a;
  --forest-400: #6a9e6a;
  --forest-300: #90c290;
  --forest-200: #c2dfc2;
  --forest-100: #e8f4e8;
  --forest-50:  #f3faf3;

  /* Accent */
  --amber:       #c97c1a;
  --amber-light: #f5e4c8;
  --red:         #b83232;
  --red-light:   #fde8e8;
  --blue:        #1e5c8a;
  --blue-light:  #dbeaf6;

  /* Neutrals */
  --ink:         #1a1f1a;
  --ink-mid:     #3d4a3d;
  --ink-light:   #6b7c6b;
  --border:      #d0dcd0;
  --border-mid:  #b0c4b0;
  --surface:     #ffffff;
  --surface-alt: #f7faf7;
  --surface-dim: #eff5ef;

  /* Typography */
  --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;

  /* Layout */
  --sidebar-w: 240px;
  --header-h:  56px;
  --radius:    6px;
  --radius-lg: 10px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(26,46,26,.1);
  --shadow:    0 2px 8px rgba(26,46,26,.12);
  --shadow-lg: 0 4px 20px rgba(26,46,26,.15);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; height: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--surface-alt);
  height: 100%;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--forest-600); text-decoration: none; }
a:hover { color: var(--forest-800); text-decoration: underline; }

/* ── Auth / Login ──────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--forest-900) 0%, var(--forest-700) 60%, var(--forest-500) 100%);
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  margin-bottom: 2rem;
}

.auth-logo .logo-icon {
  width: 96px; height: 96px;
  display: flex; align-items: center; justify-content: center;
}

.auth-logo .logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.auth-logo .logo-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--forest-800);
  text-align: center;
  line-height: 1.3;
}

.auth-logo .logo-sub {
  font-size: .8rem;
  color: var(--ink-light);
  text-align: center;
}

/* ── App Shell ─────────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--forest-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  transition: transform .2s ease;
}

.sidebar-header {
  padding: 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: .75rem;
}

.sidebar-logo-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-title { font-size: .85rem; font-weight: 600; line-height: 1.2; }
.sidebar-sub { font-size: .7rem; opacity: .6; }

.sidebar-section {
  padding: .75rem .5rem .25rem;
}

.sidebar-section-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
  padding: 0 .5rem;
  margin-bottom: .25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .75rem;
  border-radius: var(--radius);
  color: rgba(255,255,255,.75);
  font-size: .875rem;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-decoration: none;
  position: relative;
}

.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--forest-600); color: #fff; }
.nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto;
  background: var(--amber);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: .75rem .5rem;
  border-top: 1px solid rgba(255,255,255,.1);
}

.user-info {
  padding: .5rem .75rem;
  border-radius: var(--radius);
  font-size: .8rem;
}
.user-info .user-name { font-weight: 600; color: #fff; }
.user-info .user-role { color: rgba(255,255,255,.5); font-size: .72rem; }

/* Main content area */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .75rem; }

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--ink);
}

.card-body { padding: 1.25rem; }

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  transition: box-shadow .15s, transform .15s;
}

.stat-card:hover { box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,.08)); transform: translateY(-2px); }

.stat-card .stat-label { font-size: .75rem; color: var(--ink-light); font-weight: 500; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--forest-700); line-height: 1; }
.stat-card .stat-icon { font-size: 1.5rem; margin-bottom: .25rem; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-mid);
  margin-bottom: .3rem;
}
.form-label .required { color: var(--red); margin-left: 2px; }

.form-control {
  display: block;
  width: 100%;
  padding: .55rem .75rem;
  font-size: .9rem;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.form-control:focus {
  border-color: var(--forest-500);
  box-shadow: 0 0 0 3px rgba(74,122,74,.15);
}

select.form-control { cursor: pointer; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .5rem 1rem;
  font-size: .875rem;
  font-family: var(--font-sans);
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--forest-600);
  color: #fff;
  border-color: var(--forest-600);
}
.btn-primary:hover:not(:disabled) { background: var(--forest-700); border-color: var(--forest-700); }

.btn-secondary {
  background: var(--surface);
  color: var(--ink-mid);
  border-color: var(--border-mid);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-dim); }

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn-danger:hover:not(:disabled) { background: #9a2828; }

.btn-amber {
  background: var(--amber);
  color: #fff;
  border-color: var(--amber);
}
.btn-amber:hover:not(:disabled) { background: #a8661a; }

.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-icon { padding: .4rem .4rem; width: 32px; height: 32px; }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead th {
  background: var(--surface-dim);
  color: var(--ink-mid);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .65rem .9rem;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: .65rem .9rem;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--forest-50); }

/* ── Pagination ────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--ink-light);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.pagination-size {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.pagination-size .form-control {
  width: auto;
  padding: .25rem .5rem;
  font-size: .8rem;
}

.pagination-page { min-width: 90px; text-align: center; }

/* ── Calendar ──────────────────────────────────────────────────────────────── */
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.week-label {
  font-size: .95rem;
  font-weight: 600;
  color: var(--ink);
  min-width: 200px;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: 70px repeat(5, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: .8rem;
}

.cal-header {
  background: var(--forest-800);
  color: #fff;
  padding: .6rem .4rem;
  text-align: center;
  font-weight: 600;
  font-size: .75rem;
  border-right: 1px solid rgba(255,255,255,.1);
}

.cal-header:last-child { border-right: none; }

.cal-header .cal-day-name { font-size: .85rem; }
.cal-header .cal-date { font-size: .7rem; opacity: .75; }
.cal-header.holiday { background: var(--ink-mid); }

.cal-time-col {
  background: var(--surface-dim);
  color: var(--ink-light);
  font-size: .72rem;
  font-weight: 600;
  padding: .4rem .3rem;
  text-align: center;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-slot {
  padding: 3px 4px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 38px;
  cursor: pointer;
  transition: background .1s;
  display: flex;
  align-items: stretch;
}

.cal-slot:last-child { border-right: none; }

.cal-slot-inner {
  flex: 1;
  border-radius: 3px;
  display: flex;
  align-items: center;
  padding: 2px 5px;
  font-size: .72rem;
  line-height: 1.2;
  overflow: hidden;
}

/* Slot status colors */
.slot-available .cal-slot-inner {
  background: transparent;
  color: var(--ink-light);
}
.slot-available:hover .cal-slot-inner {
  background: var(--forest-100);
  color: var(--forest-700);
}

.slot-own .cal-slot-inner {
  background: var(--forest-200);
  color: var(--forest-800);
  font-weight: 600;
  cursor: pointer;
}
.slot-own:hover .cal-slot-inner { background: var(--forest-300); }

.slot-taken .cal-slot-inner {
  background: var(--blue-light);
  color: var(--blue);
  cursor: default;
}

.slot-blocked .cal-slot-inner {
  background: var(--amber-light);
  color: var(--amber);
  cursor: not-allowed;
}

.slot-deadline_passed .cal-slot-inner {
  background: var(--surface-dim);
  color: var(--border-mid);
  cursor: not-allowed;
}

/* Admin calendar - multiple per slot */
.slot-multi { flex-direction: column; gap: 2px; cursor: default; }
.slot-chip {
  border-radius: 3px;
  padding: 1px 4px;
  font-size: .68rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.chip-r1 { background: #dbedf5; color: #1a5c7a; }
.chip-r2 { background: #e8f5db; color: #3a6620; }
.chip-r3 { background: #f5ecdb; color: #7a5a1a; }
.chip-r4 { background: #f5dbdb; color: #7a1a1a; }

/* Calendar day column for holiday */
.col-holiday { opacity: .45; pointer-events: none; }

/* ── Modals ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 1rem; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--ink-light);
  padding: .1rem .3rem;
  border-radius: var(--radius);
  line-height: 1;
}
.modal-close:hover { background: var(--surface-dim); color: var(--ink); }

.modal-body { padding: 1.25rem; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
}

/* ── Badges / Tags ─────────────────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
}

.tag-green  { background: var(--forest-100); color: var(--forest-700); }
.tag-amber  { background: var(--amber-light); color: var(--amber); }
.tag-red    { background: var(--red-light); color: var(--red); }
.tag-blue   { background: var(--blue-light); color: var(--blue); }
.tag-gray   { background: var(--surface-dim); color: var(--ink-light); }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: .6rem;
}

.alert-error { background: var(--red-light); color: var(--red); border: 1px solid #f5c0c0; }
.alert-success { background: var(--forest-100); color: var(--forest-700); border: 1px solid var(--forest-200); }
.alert-warning { background: var(--amber-light); color: var(--amber); border: 1px solid #f0d0a0; }
.alert-info { background: var(--blue-light); color: var(--blue); border: 1px solid #b8d8f0; }

/* Toast */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.toast {
  padding: .75rem 1.1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  box-shadow: var(--shadow);
  max-width: 340px;
  animation: slideIn .2s ease;
  display: flex;
  align-items: center;
  gap: .6rem;
}

.toast-success { background: var(--forest-700); color: #fff; }
.toast-error   { background: var(--red); color: #fff; }
.toast-warning { background: var(--amber); color: #fff; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Misc utilities ────────────────────────────────────────────────────────── */
.flex  { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1  { margin-top: .5rem; }
.mt-2  { margin-top: 1rem; }
.mt-3  { margin-top: 1.5rem; }
.mb-1  { margin-bottom: .5rem; }
.mb-2  { margin-bottom: 1rem; }
.text-sm { font-size: .8rem; }
.text-muted { color: var(--ink-light); }
.text-center { text-align: center; }
.w-full { width: 100%; }
.hidden { display: none !important; }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--ink-light);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state .empty-text { font-size: .9rem; }

/* ── Page-specific ─────────────────────────────────────────────────────────── */

/* Calculator pages */
.calc-result-box {
  background: var(--surface-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-top: 1rem;
}

.calc-result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}

.calc-result-row:last-child { border-bottom: none; }
.calc-result-row .label { color: var(--ink-mid); }
.calc-result-row .value { font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.calc-result-row .value.warn { color: var(--red); }
.calc-result-row .value.ok   { color: var(--forest-600); }
.calc-result-row .value.deadline-green  { color: var(--forest-600); }
.calc-result-row .value.deadline-amber  { color: var(--amber); }
.calc-result-row .value.deadline-red    { color: var(--red); }

/* Notifications */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.notif-item:hover { background: var(--forest-50); }
.notif-item.unread { background: var(--forest-50); }
.notif-item.unread::before {
  content: '';
  width: 8px; height: 8px;
  background: var(--forest-500);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.notif-item.read::before {
  content: '';
  width: 8px; height: 8px;
  flex-shrink: 0;
  margin-top: 5px;
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(74,122,74,.2);
  border-top-color: var(--forest-600);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive sidebar toggle (mobile) */
@media (max-width: 768px) {
  .sidebar { position: fixed; z-index: 500; height: 100%; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.4);
    z-index: 499; display: none;
  }
  .sidebar-overlay.active { display: block; }
  .menu-toggle { display: flex !important; }
  .main-area { width: 100%; }
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: .3rem;
  font-size: 1.25rem;
  color: var(--ink-mid);
}
