/**
 * BUBY-ERP Stylesheet
 */

:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  --accent: #f59e0b;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #2563eb;
  --bg: #f1f5f9;
  --white: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-hover: #1e293b;
  --sidebar-active: #1e40af;
  --sidebar-width: 250px;
  --topbar-height: 56px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 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);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

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

/* ═══ SIDEBAR ═══ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}
.sidebar-logo span { color: var(--accent); }
.sidebar-version { font-size: .7rem; color: var(--sidebar-text); opacity: .6; margin-top: 2px; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .86rem;
  transition: all .15s;
  margin-bottom: 2px;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
  text-decoration: none;
}
.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}
.nav-icon { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; }
.nav-divider { height: 1px; background: rgba(255,255,255,.08); margin: 10px 12px; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 4px;
}
.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}
.sidebar-user-name { color: #fff; font-size: .82rem; font-weight: 600; }
.sidebar-user-role { color: var(--sidebar-text); font-size: .72rem; }

.nav-logout { color: #ef4444 !important; }
.nav-logout:hover { background: rgba(239,68,68,.15) !important; }

/* ═══ MAIN CONTENT ═══ */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-title { font-size: 1.05rem; font-weight: 700; flex: 1; }
.topbar-date { font-size: .82rem; color: var(--text-muted); }
.sidebar-toggle { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text); }

.content-area {
  padding: 24px;
  max-width: 1400px;
}

/* ═══ CARDS ═══ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-title { font-size: 1rem; font-weight: 700; }

/* ═══ STAT CARDS ═══ */
.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);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}
.stat-card .stat-label { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 800; margin-top: 4px; color: var(--text); }
.stat-card .stat-sub { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.stat-card.green { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--accent); }
.stat-card.red { border-left-color: var(--danger); }
.stat-card.blue { border-left-color: var(--info); }

/* ═══ TABLES ═══ */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
table.data-table thead th {
  padding: 10px 14px;
  text-align: left;
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .3px;
  white-space: nowrap;
}
table.data-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data-table tbody tr:hover { background: #f8fafc; }

/* ═══ FORMS ═══ */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: .84rem; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .86rem;
  font-family: inherit;
  transition: border-color .15s;
  background: var(--white);
  color: var(--text);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-textarea { resize: vertical; min-height: 80px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: .86rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  font-family: inherit;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-xs { padding: 3px 8px; font-size: .75rem; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: #f8fafc; }

/* ═══ BADGES ═══ */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fef2f2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ═══ PAGINATION ═══ */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 16px;
}
.pagination a, .pagination span {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .82rem;
  text-decoration: none;
  color: var(--text);
}
.pagination a:hover { background: #f8fafc; text-decoration: none; }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ═══ MODAL ═══ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--white);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  margin: 16px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
}
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ═══ FILTERS ═══ */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar .form-input,
.filter-bar .form-select {
  width: auto;
  min-width: 150px;
}

/* ═══ EMPTY STATE ═══ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .5; }
.empty-state-text { font-size: .92rem; }

/* ═══ LOGIN PAGE ═══ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}
.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--sidebar-bg);
}
.login-logo span { color: var(--accent); }
.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: .88rem;
  margin-bottom: 28px;
}
.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .85rem;
  margin-bottom: 16px;
  text-align: center;
}
.login-btn {
  width: 100%;
  padding: 12px;
  font-size: .95rem;
  margin-top: 8px;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .content-area { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-card { margin: 16px; padding: 28px; }
}

/* Print styles */
@media print {
  .sidebar, .topbar, .btn, .pagination { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .content-area { padding: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
