/* Custom styles on top of Tailwind */

/* === Layout: fixed sidebar + scrollable main =================== */
html, body { height: 100%; }
body { overflow: hidden; }  /* prevent the whole page from scrolling — main-area handles its own scroll */

.app-shell { height: 100vh; display: flex; overflow: hidden; }

.sidebar {
  width: 240px;
  background: #0f172a;
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;     /* persistent left rail */
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: 30;
  overflow: hidden;     /* nav has its own scroll below */
}
.sidebar-brand, .sidebar-user { flex-shrink: 0; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 0.75rem; -webkit-overflow-scrolling: touch; }
.main-area { flex: 1; min-width: 0; height: 100vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Tablet (≤ 1024px) — sidebar narrower, icon labels smaller, but stays fixed left */
@media (max-width: 1024px) and (min-width: 901px) {
  .sidebar { width: 200px; }
  .sidebar-link { font-size: 13px; padding: 0.55rem 0.85rem; }
}

/* Mobile / small tablet portrait (≤ 900px): topbar instead of side rail */
@media (max-width: 900px) {
  body { overflow: auto; }
  .app-shell { flex-direction: column; height: auto; overflow: visible; }
  .sidebar {
    position: sticky; top: 0; width: 100%; height: auto; max-height: none; overflow: visible;
  }
  .sidebar nav {
    display: flex; flex-direction: row; flex-wrap: nowrap; overflow-x: auto;
    padding: 0.5rem; gap: 0.25rem; -webkit-overflow-scrolling: touch;
  }
  .sidebar .sidebar-brand, .sidebar .sidebar-user { display: none; }
  .sidebar-link { white-space: nowrap; padding: 0.5rem 0.75rem; font-size: 13px; min-height: 44px; }
  .main-area { max-height: none; height: auto; overflow: visible; }
  .mobile-topbar { display: flex !important; }
}
.mobile-topbar {
  display: none; align-items: center; justify-content: space-between;
  padding: 0.5rem 0.75rem; background: #fff; border-bottom: 1px solid #e2e8f0;
  position: sticky; top: 0; z-index: 25;
}

.sidebar-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem; border-radius: 0.5rem;
  color: #cbd5e1; transition: all 0.15s;
  min-height: 44px;        /* iOS HIG / Material touch target */
  touch-action: manipulation;
}
.sidebar-link:hover { background: rgba(255,255,255,0.06); color:#fff; }
.sidebar-link.active { background: linear-gradient(90deg, #1447e6 0%, #155dfc 100%); color:#fff; box-shadow: 0 2px 8px rgba(20,71,230,0.4); }
.sidebar-link i { width: 20px; text-align: center; }

.card { background:#fff; border-radius:0.75rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border:1px solid #e2e8f0; }

.chip { display:inline-block; padding:2px 10px; border-radius:999px; font-size:11px; font-weight:600; }
.chip-green { background:#dcfce7; color:#166534; }
.chip-red { background:#fee2e2; color:#991b1b; }
.chip-amber { background:#fef3c7; color:#92400e; }
.chip-blue { background:#dbeefe; color:#1447e6; }
.chip-slate { background:#f1f5f9; color:#475569; }

/* === Touch / tablet friendly tweaks ============================ */
.input {
  width:100%; border:1px solid #cbd5e1; border-radius:0.5rem;
  padding:0.55rem 0.75rem; font-size:14px; transition: all 0.15s;
  min-height: 44px;        /* finger-friendly */
  background: #fff;
}
.input:focus { outline:none; border-color:#1447e6; box-shadow: 0 0 0 3px rgba(20,71,230,0.15); }

.btn-primary, .btn-ghost, .btn-danger {
  min-height: 44px; touch-action: manipulation;
  display:inline-flex; align-items:center; gap:0.5rem;
  padding:0.55rem 1.1rem; border-radius:0.5rem; font-weight:500; transition: all 0.15s;
  cursor: pointer; user-select: none;
}
.btn-primary { background:#1447e6; color:#fff; }
.btn-primary:hover { background:#193cb8; }
.btn-primary:disabled { opacity:0.5; cursor:not-allowed; }
.btn-ghost { background:#fff; color:#1447e6; border:1px solid #1447e6; }
.btn-ghost:hover { background:#eff8ff; }
.btn-danger { background:#dc2626; color:#fff; }
.btn-danger:hover { background:#991b1b; }

button, select, input[type=date], input[type=datetime-local] { touch-action: manipulation; }

/* iOS Safari: prevent the auto-zoom-on-focus that breaks form layout on tablets */
@media (max-width: 1024px) {
  .input, select.input, textarea.input { font-size: 16px; }
}

.table-responsive { overflow-x:auto; -webkit-overflow-scrolling: touch; }
table.data { width:100%; font-size:13px; border-collapse:collapse; }
table.data th { text-align:left; padding:10px 12px; background:#f8fafc; color:#64748b; font-weight:600; border-bottom:1px solid #e2e8f0; font-size:11px; text-transform:uppercase; letter-spacing:0.5px; }
table.data td { padding:10px 12px; border-bottom:1px solid #f1f5f9; }
table.data tr:hover td { background:#f8fafc; }

@media (max-width: 1024px) {
  table.data { font-size: 12.5px; }
  table.data td, table.data th { padding: 8px 10px; }
}
@media (max-width: 768px) {
  table.data { font-size: 12px; }
  table.data td, table.data th { padding: 6px 8px; }
  .text-2xl { font-size: 1.25rem !important; }
  .p-6 { padding: 14px !important; }
  .modal { max-height: 95vh; padding: 16px !important; }
}

.toast-container { position: fixed; top:20px; right:20px; z-index:9999; }
.toast { background:#fff; border-left:4px solid #1447e6; box-shadow:0 4px 12px rgba(0,0,0,0.1); padding:12px 18px; border-radius:6px; margin-bottom:8px; min-width:240px; animation: slideIn 0.25s; font-size:14px; }
.toast.error { border-color:#dc2626; }
.toast.success { border-color:#16a34a; }
@keyframes slideIn { from { transform:translateX(100%); opacity:0; } to { transform:translateX(0); opacity:1; } }

.modal-backdrop { position:fixed; inset:0; background:rgba(15,23,42,0.55); z-index:100; display:flex; align-items:center; justify-content:center; padding:20px; }
.modal { background:#fff; border-radius:0.75rem; max-width:720px; width:100%; max-height:90vh; overflow-y:auto; padding: 20px; -webkit-overflow-scrolling: touch; }

.loader { display:inline-block; width:20px; height:20px; border:3px solid #e2e8f0; border-top-color:#1447e6; border-radius:50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.power-input { text-align:center; }

/* Compact analytics charts (smaller fixed heights) */
.chart-sm { position: relative; height: 180px; max-height: 180px; }
.chart-sm canvas { max-height: 180px !important; }

/* Print helper */
@media print { .no-print { display:none !important; } }
