/* ============================================================
   PTMS — Compatibility & Component CSS
   Tailwind CDN handles layout. This file covers legacy
   component classes used by module pages.
   ============================================================ */

/* ── CSS Variables (used by all module pages inline styles) ── */
:root {
  --accent:       #3b82f6;
  --accent-dark:  #2563eb;
  --accent-light: #eff6ff;
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --info:         #06b6d4;
  --purple:       #8b5cf6;
  --sidebar-bg:   #0f172a;
  --body-bg:      #f8fafc;
  --card-bg:      #ffffff;
  --border:       #e2e8f0;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --dark:         #1e293b;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 1px 3px rgba(0,0,0,.06),0 4px 12px rgba(0,0,0,.04);
  --shadow-md:    0 4px 16px rgba(0,0,0,.08);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
body { font-family: ui-sans-serif, system-ui, -apple-system, sans-serif; }

/* ── Legacy page layout (non-dashboard pages still use these) ── */
.layout       { display: flex; min-height: 100vh; }
.main-wrap    { margin-left: 230px; width: calc(100% - 230px); min-width: 0; display: flex; flex-direction: column; }
.page-body    { padding: 24px; flex: 1; background: #f8fafc; width: 100%; }

/* ── Cards ── */
.card         { background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06),0 4px 12px rgba(0,0,0,.04); overflow: hidden; margin-bottom: 16px; }
.card-header  { padding: 14px 20px; border-bottom: 1px solid #f1f5f9; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-header h3 { font-size: 14px; font-weight: 700; margin: 0; }
.card-body    { padding: 20px; }

/* ── Page header ── */
.page-header  { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }
.page-header h1 { font-size: 22px; font-weight: 800; margin: 0; }

/* ── Tables ── */
.table-wrap   { overflow-x: auto; }
.data-table   { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table thead tr { border-bottom: 2px solid #f1f5f9; background: #f8fafc; }
.data-table th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #64748b; white-space: nowrap; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid #f8fafc; vertical-align: middle; }
.data-table tbody tr:hover { background: #fafbff; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Forms ── */
.form-grid    { display: grid; grid-template-columns: repeat(auto-fill,minmax(260px,1fr)); gap: 16px; }
.form-group   { display: flex; flex-direction: column; gap: 5px; }
.form-group.full-width { grid-column: 1/-1; }
label         { font-size: 12.5px; font-weight: 600; color: #1e293b; }
label .required { color: #ef4444; }
input[type=text],input[type=email],input[type=password],
input[type=tel],input[type=date],input[type=number],select,textarea {
  padding: 9px 12px; border: 1.5px solid #e2e8f0; border-radius: 8px;
  font-size: 13.5px; background: #fff; color: #1e293b; width: 100%;
  transition: border .15s, box-shadow .15s; font-family: inherit;
}
input:focus,select:focus,textarea:focus {
  outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: 11.5px; color: #64748b; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px; border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer; border: none; transition: all .15s; white-space: nowrap; text-decoration: none; font-family: inherit; }
.btn-primary   { background: #2563eb; color: #fff; }
.btn-primary:hover  { background: #1d4ed8; color: #fff; }
.btn-success   { background: #10b981; color: #fff; }
.btn-success:hover  { background: #059669; }
.btn-danger    { background: #ef4444; color: #fff; }
.btn-danger:hover   { background: #dc2626; }
.btn-warning   { background: #f59e0b; color: #fff; }
.btn-secondary { background: #f8fafc; border: 1.5px solid #e2e8f0; color: #374151; }
.btn-secondary:hover { background: #f1f5f9; }
.btn-outline   { background: transparent; border: 1.5px solid #3b82f6; color: #3b82f6; }
.btn-outline:hover { background: #3b82f6; color: #fff; }
.btn-sm  { padding: 6px 13px; font-size: 12.5px; }
.btn-xs  { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-icon{ padding: 8px; border-radius: 8px; background: #f8fafc; color: #64748b; border: 1.5px solid #e2e8f0; cursor: pointer; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-primary   { background: #eff6ff; color: #1d4ed8; }
.badge-success   { background: #ecfdf5; color: #065f46; }
.badge-warning   { background: #fffbeb; color: #92400e; }
.badge-danger    { background: #fef2f2; color: #991b1b; }
.badge-info      { background: #ecfeff; color: #0e7490; }
.badge-secondary { background: #f1f5f9; color: #64748b; }
.badge-purple    { background: #f5f3ff; color: #5b21b6; }
.badge-dark      { background: #1e293b; color: #fff; }

/* ── Progress ── */
.progress-wrap  { background: #e2e8f0; border-radius: 20px; height: 8px; overflow: hidden; position: relative; }
.progress-bar   { height: 100%; border-radius: 20px; transition: width .4s; }
.progress-label { position: absolute; right:0; top:-18px; font-size:11px; font-weight:700; color:#64748b; }
.bg-success { background: #10b981; }
.bg-primary { background: #3b82f6; }
.bg-warning { background: #f59e0b; }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: 8px; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; font-size: 13.5px; line-height: 1.5; }
.alert-success { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }

/* ── Action Points ── */
.action-list  { list-style: none; padding: 0; margin: 0; }
.action-item  { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f1f5f9; }
.action-item:last-child { border-bottom: none; }
.action-check { width: 20px; height: 20px; border: 2px solid #e2e8f0; border-radius: 5px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px; cursor: pointer; transition: all .15s; }
.action-check.done { background: #10b981; border-color: #10b981; color: #fff; }
.action-text  { flex: 1; }
.action-text .ap-title { font-weight: 600; font-size: 14px; }
.action-text .ap-desc  { font-size: 12.5px; color: #64748b; margin-top: 2px; }
.action-text.completed .ap-title { text-decoration: line-through; color: #94a3b8; }

/* ── Misc ── */
.divider    { border: none; border-top: 1px solid #e2e8f0; margin: 16px 0; }
.text-muted { color: #64748b; }
.text-sm    { font-size: 12.5px; }
.fw-600     { font-weight: 600; }
.hidden     { display: none !important; }
.inline-progress { display: flex; align-items: center; gap: 8px; }
.inline-progress .bar-track { flex:1; min-width:60px; height:6px; background:#e2e8f0; border-radius:20px; overflow:hidden; }
.inline-progress .bar-fill  { height:100%; border-radius:20px; transition:width .4s; }
.inline-progress .bar-pct   { font-size:12px; font-weight:700; color:#64748b; white-space:nowrap; }
.grid-2  { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.empty-state { text-align:center; padding:40px 20px; color:#64748b; }
.empty-state .empty-icon { font-size:40px; margin-bottom:10px; }

/* ── Login page ── */
.login-page  { min-height:100vh; display:flex; background:#0f172a; }
.login-right { width:480px; flex-shrink:0; min-height:100vh; display:flex; align-items:center; justify-content:center; background:rgba(255,255,255,.97); padding:48px 36px; box-shadow:-6px 0 48px rgba(0,0,0,.3); }
.login-left  { flex:1; display:flex; align-items:center; justify-content:center; padding:60px 56px; }
.login-box   { width:100%; max-width:390px; }
.login-form-logo { max-height:62px; max-width:190px; object-fit:contain; margin-bottom:14px; display:block; }
.login-brand { text-align:center; margin-bottom:30px; }
.login-brand h2 { font-size:24px; font-weight:800; margin-bottom:4px; }
.logo-icon   { width:54px; height:54px; background:#3b82f6; border-radius:14px; display:flex; align-items:center; justify-content:center; font-size:24px; color:#fff; margin:0 auto 14px; }

/* ═══════════════════════════════════════════════
   MOBILE / RESPONSIVE IMPROVEMENTS
═══════════════════════════════════════════════ */

/* Tablet and below */
@media(max-width:900px){
  .main-wrap  { margin-left:0 !important; width:100% !important; }
  .grid-2, .grid-3 { grid-template-columns:1fr; }
  .page-body  { padding: 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .card-header { flex-wrap: wrap; }
  .form-grid  { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .data-table th, .data-table td { padding: 8px 10px; font-size: 12.5px; }
}

/* Phone — 640px and below */
@media(max-width:640px){
  .page-header h1 { font-size: 18px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card  { padding: 14px; gap: 10px; }
  .stat-value { font-size: 22px; }
  .stat-icon  { width: 36px; height: 36px; font-size: 15px; }
  .btn        { padding: 8px 14px; font-size: 13px; }
  .btn-sm     { padding: 5px 10px; font-size: 12px; }

  /* Tables — scroll horizontally on phone */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 600px; }

  /* Cards */
  .card-body  { padding: 14px; }
  .card-header { padding: 12px 14px; }

  /* Forms */
  input[type=text],input[type=email],input[type=password],
  input[type=tel],input[type=date],input[type=number],select,textarea {
    font-size: 16px; /* prevents iOS zoom on focus */
    padding: 10px 12px;
  }

  /* Alerts */
  .alert { font-size: 13px; padding: 10px 13px; }

  /* Login page */
  .login-page  { flex-direction: column; }
  .login-right { width: 100%; padding: 32px 20px; box-shadow: none; }
  .login-left  { display: none; }

  /* Badges — wrap if many */
  .badge { font-size: 11px; padding: 2px 7px; }

  /* Progress label on narrow screens */
  .progress-label { display: none; }
}

/* ═══════════════════════════════════════════════
   STAT CARDS (used by reports, technician view,
   project view and other module pages)
═══════════════════════════════════════════════ */
.stats-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  background: #fff !important;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
  display: flex !important;
  align-items: flex-start !important;
  gap: 14px;
  border-top: 3px solid transparent;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.stat-card.blue   { border-top-color: #3b82f6; }
.stat-card.green  { border-top-color: #10b981; }
.stat-card.orange { border-top-color: #f59e0b; }
.stat-card.red    { border-top-color: #ef4444; }
.stat-card.purple { border-top-color: #8b5cf6; }
.stat-card.teal   { border-top-color: #06b6d4; }

.stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; flex-shrink: 0;
}
.stat-card.blue   .stat-icon { background: #eff6ff; color: #3b82f6; }
.stat-card.green  .stat-icon { background: #ecfdf5; color: #10b981; }
.stat-card.orange .stat-icon { background: #fffbeb; color: #f59e0b; }
.stat-card.red    .stat-icon { background: #fef2f2; color: #ef4444; }
.stat-card.purple .stat-icon { background: #f5f3ff; color: #8b5cf6; }
.stat-card.teal   .stat-icon { background: #ecfeff; color: #06b6d4; }

.stat-value {
  font-size: 28px; font-weight: 800; line-height: 1.1;
  color: #1e293b;
}
.stat-card.green .stat-value { color: #10b981; }
.stat-card.red   .stat-value { color: #ef4444; }

.stat-label { font-size: 12px; color: #64748b; margin-top: 3px; font-weight: 500; }
.stat-sub   { font-size: 11px; margin-top: 4px; font-weight: 600; color: #64748b; }
.stat-card.green  .stat-sub { color: #10b981; }
.stat-card.orange .stat-sub { color: #f59e0b; }
.stat-card.red    .stat-sub { color: #ef4444; }

/* ── Page header fix ── */
.page-header h1 { font-size: 22px; font-weight: 800; }

/* ── View-all link ── */
.view-all { font-size: 12px; font-weight: 600; color: #3b82f6; text-decoration: none; }
.view-all:hover { color: #2563eb; }
