/* ═══════════════════════════════════════════════════════
   SALGA DAR System — Full Responsive Stylesheet
   Mobile-first · works on phones, tablets, laptops, desktops
   ═══════════════════════════════════════════════════════ */

:root{
  --tiger-orange:#f07d00;
  --golden-sand:#e1c869;
  --black:#000000;
  --white:#ffffff;
  --white-smoke:#f2f2f2;
  --graphite:#333333;
  --shadow:0 4px 6px rgba(0,0,0,.1);
  --shadow-lg:0 10px 30px rgba(0,0,0,.15);
  --radius:8px;
  --radius-lg:12px;
  --transition:all .3s ease;

  --header-h:64px;
  --content-max:1400px;
}

/* ─────────── Reset ─────────── */
*,*::before,*::after{box-sizing:border-box;}
html,body{margin:0;padding:0;}
html{-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent;}

/* Images scale down but never overflow — height:auto is REMOVED so logo sizing works */
img,video,canvas,svg{max-width:100%;display:block;}

button,input,select,textarea{font:inherit;color:inherit;}
a{color:var(--tiger-orange);text-decoration:none;}
a:hover{text-decoration:underline;}

body{
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Arial,sans-serif;
  background:var(--white-smoke);
  color:var(--graphite);
  line-height:1.55;
  min-height:100vh;
  min-height:100dvh;
  display:flex;
  flex-direction:column;
  overflow-x:hidden;
}

/* ─────────── Typography (fluid) ─────────── */
h1,h2,h3,h4,h5,h6{color:var(--black);font-weight:700;line-height:1.25;margin:0 0 .6rem;}
h1{font-size:clamp(1.35rem,2.4vw + 1rem,2.5rem);}
h2{font-size:clamp(1.2rem,1.6vw + .9rem,1.9rem);}
h3{font-size:clamp(1.05rem,1vw + .85rem,1.4rem);}
h4{font-size:clamp(1rem,.6vw + .85rem,1.2rem);}
p{margin:0 0 .75rem;}

/* ═══════════════ HEADER ═══════════════ */
.salga-header{
  background:var(--black);
  color:var(--white);
  min-height:var(--header-h);
  padding:.6rem 1rem;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:.75rem;
  flex-wrap:wrap;
  position:sticky;
  top:0;
  z-index:1000;
  box-shadow:0 2px 4px rgba(0,0,0,.2);
}

/* ─── Logo with white pill ─── */
.salga-header .logo{display:flex;align-items:center;flex-shrink:0;}
.salga-header .logo a{display:flex;align-items:center;text-decoration:none;}
.salga-header .logo a > span:first-child{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:#ffffff;
  border-radius:8px;
  padding:6px 14px;
  height:44px;
  max-height:44px;
  box-shadow:0 1px 3px rgba(0,0,0,.2);
  flex-shrink:0;
  transition:transform .2s ease, box-shadow .2s ease;
}
.salga-header .logo a:hover > span:first-child{
  transform:translateY(-1px);
  box-shadow:0 3px 8px rgba(0,0,0,.3);
}
.salga-header .logo a > span:first-child img{
  height:32px !important;
  max-height:32px !important;
  width:auto !important;
  max-width:150px !important;
  object-fit:contain;
  display:block;
}
.salga-header .logo a > span:first-child span{
  color:#f07d00;
  font-weight:900;
  font-size:1rem;
  letter-spacing:.5px;
  line-height:1;
}

/* ─── Nav ─── */
.salga-header .nav{
  display:flex;gap:1.2rem;align-items:center;flex-wrap:wrap;
}
.salga-header .nav a{
  color:var(--white);text-decoration:none;font-size:.85rem;font-weight:500;
  padding:.35rem 0;border-bottom:2px solid transparent;
  white-space:nowrap;transition:border-color .2s;
}
.salga-header .nav a:hover,
.salga-header .nav a.active{border-bottom-color:var(--tiger-orange);}
.salga-header .nav a.active{color:var(--tiger-orange);}

/* ─── User menu ─── */
.salga-header .user-menu{display:flex;align-items:center;gap:.75rem;flex-wrap:wrap;}
.salga-header .user-menu .user-profile{display:flex;align-items:center;gap:.5rem;}
.salga-header .user-menu .avatar{
  width:32px;height:32px;border-radius:50%;
  background:var(--golden-sand);color:var(--black);
  display:flex;align-items:center;justify-content:center;
  font-weight:700;font-size:.8rem;
}
.salga-header .user-menu .user-profile > div > div:first-child{font-size:.8rem;font-weight:600;}
.salga-header .user-menu .user-profile > div > div:last-child{font-size:.7rem;opacity:.75;}

/* ═══════════════ FOOTER ═══════════════ */
.salga-footer{
  background:var(--black);color:var(--white);
  padding:.9rem 1rem;text-align:center;font-size:.8rem;margin-top:auto;
}
.salga-footer .footer-content{
  max-width:var(--content-max);margin:0 auto;
  display:flex;justify-content:space-between;align-items:center;gap:.75rem;flex-wrap:wrap;
}

/* ═══════════════ MAIN ═══════════════ */
main{flex:1;display:flex;flex-direction:column;}
.main-content{
  width:100%;
  max-width:var(--content-max);
  margin:0 auto;
  padding:1.25rem 1rem;
  flex:1;
}
.page-header{margin-bottom:1.25rem;}
.page-header .subtitle{color:var(--graphite);font-size:.95rem;}

/* ═══════════════ CARDS ═══════════════ */
.card{
  background:var(--white);border:1px solid rgba(0,0,0,.05);
  border-radius:var(--radius);box-shadow:var(--shadow);
  padding:1.1rem;margin-bottom:1rem;transition:var(--transition);
}
.card:hover{box-shadow:var(--shadow-lg);}
.card-header{
  display:flex;justify-content:space-between;align-items:center;
  gap:.75rem;flex-wrap:wrap;
  padding-bottom:.6rem;margin-bottom:.9rem;
  border-bottom:1px solid var(--white-smoke);
}
.card-header h3{margin:0;}
.card-body{padding:.25rem 0;}

/* ═══════════════ BUTTONS ═══════════════ */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:.35rem;
  padding:.7rem 1.15rem;border:none;border-radius:var(--radius);
  font-weight:600;font-size:.92rem;line-height:1.2;cursor:pointer;
  text-align:center;text-decoration:none;transition:var(--transition);
  min-height:44px;
  -webkit-tap-highlight-color:transparent;
}
.btn:disabled{opacity:.6;cursor:not-allowed;}

.btn-primary{background:var(--tiger-orange);color:var(--white);}
.btn-primary:hover:not(:disabled){background:#d96e00;transform:translateY(-1px);box-shadow:0 4px 12px rgba(240,125,0,.3);}

.btn-secondary{background:var(--golden-sand);color:var(--black);}
.btn-secondary:hover:not(:disabled){background:#d1b85a;transform:translateY(-1px);}

.btn-neutral{background:var(--graphite);color:var(--white);}
.btn-neutral:hover:not(:disabled){background:#1a1a1a;}

.btn-outline{background:transparent;color:var(--tiger-orange);border:2px solid var(--tiger-orange);}
.btn-outline:hover:not(:disabled){background:var(--tiger-orange);color:var(--white);}

.btn-success{background:#28a745;color:var(--white);}
.btn-success:hover:not(:disabled){background:#218838;}
.btn-danger{background:#dc3545;color:var(--white);}
.btn-danger:hover:not(:disabled){background:#c82333;}

.btn-sm{padding:.45rem .8rem;font-size:.8rem;min-height:36px;}
.btn-lg{padding:1rem 1.6rem;font-size:1.05rem;min-height:52px;}
.btn-block{display:flex;width:100%;}

/* ═══════════════ KPI CARDS ═══════════════ */
.kpi-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(150px,1fr));
  gap:.85rem;margin-bottom:1.25rem;
}
.kpi-card{
  background:var(--white);border:1px solid rgba(0,0,0,.04);
  border-left:4px solid var(--tiger-orange);
  border-radius:var(--radius);padding:1rem;
  box-shadow:var(--shadow);transition:var(--transition);
}
.kpi-card:hover{transform:translateY(-2px);box-shadow:var(--shadow-lg);}
.kpi-card .kpi-number{font-size:clamp(1.5rem,3vw + .8rem,2.25rem);font-weight:700;color:var(--black);line-height:1.1;}
.kpi-card .kpi-label{color:var(--graphite);font-size:.85rem;margin-top:.15rem;}
.kpi-card .kpi-icon{float:right;font-size:1.5rem;color:var(--golden-sand);}
.kpi-card.accent-gold{border-left-color:var(--golden-sand);}
.kpi-card.accent-green{border-left-color:#28a745;}
.kpi-card.accent-red{border-left-color:#dc3545;}
.kpi-card.accent-blue{border-left-color:#2196F3;}

/* ═══════════════ FORMS ═══════════════ */
.form-group{margin-bottom:1rem;}
.form-group label{display:block;font-weight:600;margin-bottom:.35rem;color:var(--black);font-size:.9rem;}
.form-group input,
.form-group select,
.form-group textarea{
  width:100%;padding:.75rem .9rem;border:1px solid #ddd;
  border-radius:var(--radius);font-size:1rem;background:var(--white);
  transition:border-color .2s,box-shadow .2s;
  min-height:44px;
}
.form-group textarea{min-height:90px;resize:vertical;}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus{
  outline:none;border-color:var(--tiger-orange);
  box-shadow:0 0 0 3px rgba(240,125,0,.1);
}
.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea{border-color:#dc3545;}
.form-group .help-text{font-size:.8rem;color:var(--graphite);opacity:.85;margin-top:.25rem;display:block;}
.form-group .error-text{font-size:.8rem;color:#dc3545;margin-top:.25rem;display:block;}

.form-row{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:1rem;}

.form-actions{
  display:flex;gap:.75rem;flex-wrap:wrap;
  padding-top:1rem;margin-top:1rem;border-top:1px solid var(--white-smoke);
}
.form-actions .btn{flex:1 1 180px;}

/* ═══════════════ TABLES ═══════════════ */
.table-responsive{
  width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;
  border-radius:var(--radius);
}
.table{width:100%;border-collapse:collapse;font-size:.9rem;min-width:600px;}
.table thead{background:var(--white-smoke);color:var(--graphite);}
.table th{padding:.7rem .85rem;text-align:left;font-weight:600;border-bottom:2px solid #e0e0e0;white-space:nowrap;}
.table td{padding:.7rem .85rem;border-bottom:1px solid var(--white-smoke);vertical-align:top;}
.table tbody tr:hover{background:rgba(240,125,0,.05);}

.status-badge{
  display:inline-block;padding:.2rem .65rem;border-radius:999px;
  font-size:.75rem;font-weight:600;white-space:nowrap;line-height:1.4;
}
.status-badge.open{background:var(--tiger-orange);color:var(--white);}
.status-badge.completed{background:var(--golden-sand);color:var(--black);}
.status-badge.draft{background:var(--white-smoke);color:var(--graphite);}
.status-badge.cancelled{background:#dc3545;color:var(--white);}
.status-badge.in-progress{background:#2196F3;color:var(--white);}
.status-badge.pending{background:#ffc107;color:var(--black);}
.status-badge.confirmed{background:#28a745;color:var(--white);}
.status-badge.checked-in{background:#17a2b8;color:var(--white);}

/* ═══════════════ ALERTS ═══════════════ */
.alert{padding:.9rem 1rem;border-radius:var(--radius);margin-bottom:1rem;border:1px solid transparent;font-size:.9rem;}
.alert-success{background:#d4edda;border-color:#c3e6cb;color:#155724;}
.alert-danger{background:#f8d7da;border-color:#f5c6cb;color:#721c24;}
.alert-warning{background:#fff3cd;border-color:#ffeaa7;color:#856404;}
.alert-info{background:#d1ecf1;border-color:#bee5eb;color:#0c5460;}

/* ═══════════════ FILTERS ═══════════════ */
.filters-bar{
  background:var(--white);border-radius:var(--radius);
  box-shadow:var(--shadow);padding:1rem;margin-bottom:1rem;
}
.filters-bar .filter-row{
  display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:.75rem;
}
.filters-bar .filter-row .form-group{margin-bottom:0;}

/* ═══════════════ CHECK-IN / QR SCREENS ═══════════════ */
.checkin-screen{
  min-height:calc(100vh - var(--header-h));
  background:var(--white-smoke);
  display:flex;align-items:flex-start;justify-content:center;
  padding:1.25rem 1rem;
}
.checkin-screen .checkin-container{
  background:var(--white);border-radius:var(--radius-lg);
  box-shadow:var(--shadow-lg);padding:1.5rem;
  max-width:680px;width:100%;text-align:center;
}
.checkin-screen h1{font-size:clamp(1.4rem,2.4vw + 1rem,2.4rem);}
.checkin-screen .subtitle{color:var(--graphite);margin-bottom:1.25rem;}

.checkin-buttons{
  display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));
  gap:.75rem;margin:1.25rem 0;
}
.checkin-buttons .btn{padding:1rem .9rem;font-size:.98rem;min-height:64px;line-height:1.3;}

#qr-box img{width:100%;max-width:340px;height:auto;}

video#scanner{width:100%;border-radius:var(--radius);}

.signature-pad canvas,
canvas#sig,
canvas#sig-canvas{
  width:100%!important;height:auto!important;min-height:150px;
  background:#fff;border-radius:var(--radius);touch-action:none;
}

/* ═══════════════ MODALS ═══════════════ */
.modal-overlay{
  display:none;position:fixed;inset:0;background:rgba(0,0,0,.5);
  z-index:2000;align-items:center;justify-content:center;padding:1rem;
}
.modal-overlay.active{display:flex;}
.modal{
  background:var(--white);border-radius:var(--radius-lg);
  max-width:600px;width:100%;max-height:90vh;overflow-y:auto;
  padding:1.5rem;box-shadow:var(--shadow-lg);
}
.modal-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:1rem;padding-bottom:.5rem;border-bottom:1px solid var(--white-smoke);}
.modal-header .close{background:none;border:none;font-size:1.5rem;cursor:pointer;color:var(--graphite);}
.modal-footer{display:flex;justify-content:flex-end;gap:.75rem;margin-top:1rem;padding-top:1rem;border-top:1px solid var(--white-smoke);flex-wrap:wrap;}

/* ═══════════════════════════════════════════════════════
   AUTH PAGES (login, signup, forgot, reset)
   ═══════════════════════════════════════════════════════ */
.auth-bg{
  background: var(--white-smoke);
  background-image:
    radial-gradient(circle at 20% 20%, rgba(240,125,0,.06) 0%, transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(225,200,105,.08) 0%, transparent 45%);
  background-attachment: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1rem;
  margin: 0;
  overflow-x: hidden;
}

.auth-card{
  max-width: 420px;
  width: 100%;
  padding: 2rem 1.5rem;
  text-align: center;
  border-top: 4px solid var(--tiger-orange);
  box-shadow: 0 12px 40px rgba(0,0,0,.10);
  margin: auto;
}
.auth-card .auth-logo{
  height: 80px;
  width: auto;
  margin: 0 auto 1rem;
  display: block;
}
.auth-card h1{
  font-size: 1.4rem;
  margin: 0;
  color: var(--black);
}
.auth-card .auth-subtitle{
  color: var(--graphite);
  margin: .25rem 0 1.5rem;
}
.auth-card form{ text-align: left; }
.auth-card .divider{
  margin: 1.25rem 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  color: #aaa;
  font-size: .85rem;
}
.auth-card .divider::before,
.auth-card .divider::after{
  content: '';
  flex: 1;
  height: 1px;
  background: #ddd;
}
.auth-card .copyright{
  color: var(--graphite);
  font-size: .8rem;
  margin-top: 1.5rem;
  opacity: .75;
}

/* ═══════════════ UTILITIES ═══════════════ */
.text-center{text-align:center;} .text-right{text-align:right;} .text-left{text-align:left;}
.text-muted{color:var(--graphite);opacity:.75;} .text-success{color:#28a745;} .text-danger{color:#dc3545;} .text-primary{color:var(--tiger-orange);}
.mt-1{margin-top:.5rem;} .mt-2{margin-top:1rem;} .mt-3{margin-top:1.5rem;} .mt-4{margin-top:2rem;}
.mb-1{margin-bottom:.5rem;} .mb-2{margin-bottom:1rem;} .mb-3{margin-bottom:1.5rem;} .mb-4{margin-bottom:2rem;}
.d-flex{display:flex;} .d-grid{display:grid;}
.gap-1{gap:.5rem;} .gap-2{gap:1rem;} .gap-3{gap:1.5rem;}
.align-center{align-items:center;} .justify-between{justify-content:space-between;} .justify-center{justify-content:center;}
.w-100{width:100%;} .h-100{height:100%;}
.flex-wrap{flex-wrap:wrap;}
.hidden{display:none !important;}

/* ═══════════════ ANIMATIONS ═══════════════ */
@keyframes fadeIn{from{opacity:0;transform:translateY(8px);}to{opacity:1;transform:none;}}
.fade-in{animation:fadeIn .3s ease-out;}
@keyframes pulse{0%,100%{transform:scale(1);}50%{transform:scale(1.04);}}
.pulse{animation:pulse 2s infinite;}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════ */

/* ── Tablets and small laptops ── */
@media (min-width:769px){
  .main-content{padding:1.75rem 1.5rem;}
  .card{padding:1.4rem;}
  .kpi-grid{grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:1rem;}
  .checkin-screen{padding:2rem;}
  .checkin-screen .checkin-container{padding:2.25rem;}
}

/* ── Phones (<=768px) ── */
@media (max-width:768px){
  .salga-header{padding:.5rem .75rem;gap:.5rem;min-height:56px;}

  .salga-header .logo a > span:first-child{
    padding:4px 10px;
    height:38px;
    max-height:38px;
  }
  .salga-header .logo a > span:first-child img{
    height:24px !important;
    max-height:24px !important;
    max-width:100px !important;
  }

  .salga-header .nav{
    order:3;
    width:100%;
    overflow-x:auto;
    flex-wrap:nowrap;
    gap:1rem;
    padding-top:.4rem;
    padding-bottom:.2rem;
    border-top:1px solid rgba(255,255,255,.08);
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
  }
  .salga-header .nav::-webkit-scrollbar{display:none;}
  .salga-header .nav a{font-size:.78rem;padding:.3rem 0;}

  .salga-header .user-menu{gap:.4rem;}
  .salga-header .user-menu .user-profile > div{display:none;}
  .salga-header .user-menu .avatar{width:30px;height:30px;font-size:.75rem;}
  .salga-header .user-menu a[href*="logout"]{
    font-size:.72rem !important;
    padding:.4rem .7rem !important;
  }

  .kpi-grid{grid-template-columns:repeat(2,1fr);gap:.6rem;}
  .kpi-card{padding:.75rem;}
  .kpi-card .kpi-icon{font-size:1.2rem;}
  .kpi-card .kpi-number{font-size:1.5rem;}
  .kpi-card .kpi-label{font-size:.78rem;}

  .main-content{padding:1rem .75rem;}

  .checkin-screen{padding:.9rem;}
  .checkin-screen .checkin-container{padding:1rem;border-radius:var(--radius);}
  .checkin-buttons{grid-template-columns:1fr;gap:.5rem;}
  .checkin-buttons .btn{min-height:56px;padding:.9rem .75rem;font-size:.95rem;}

  .form-actions{flex-direction:column;}
  .form-actions .btn{width:100%;}

  .filters-bar{padding:.85rem;}
  .filters-bar .filter-row{grid-template-columns:1fr;}

  .salga-footer .footer-content{flex-direction:column;text-align:center;gap:.4rem;}

  .modal{padding:1.1rem;}

  .table{font-size:.82rem;min-width:720px;}
  .table th,.table td{padding:.55rem .6rem;}

  /* Auth pages on phones */
  .auth-bg{ padding: .75rem; align-items: flex-start; padding-top: 1.5rem; }
  .auth-card{
    padding: 1.5rem 1rem;
    border-top-width: 3px;
    border-radius: 10px;
  }
  .auth-card .auth-logo{ height: 64px; margin-bottom: .75rem; }
  .auth-card h1{ font-size: 1.2rem; }
  .auth-card .auth-subtitle{ font-size: .9rem; margin-bottom: 1.1rem; }
  .auth-card .copyright{ font-size: .72rem; margin-top: 1rem; }
}

/* ── Small phones (<=420px) ── */
@media (max-width:420px){
  .kpi-grid{grid-template-columns:1fr;}
  .checkin-screen h1{font-size:1.3rem;}
  .btn-lg{padding:.85rem 1.2rem;font-size:.98rem;}
  .card{padding:.9rem;}
  .card-header h3{font-size:1.05rem;}

  .salga-header{padding:.45rem .6rem;}
  .salga-header .logo a > span:first-child{
    padding:4px 8px;
    height:34px;
    max-height:34px;
  }
  .salga-header .logo a > span:first-child img{
    height:22px !important;
    max-height:22px !important;
    max-width:100px !important;
  }
  .salga-header .nav a{font-size:.74rem;}
  .salga-header .user-menu a[href*="logout"]{font-size:.68rem !important;padding:.35rem .55rem !important;}

  .table{min-width:620px;font-size:.78rem;}
}

/* ── Very small phones (<=360px) ── */
@media (max-width:360px){
  .auth-card{ padding: 1.25rem .85rem; }
  .auth-card .auth-logo{ height: 56px; }
  .auth-card h1{ font-size: 1.1rem; }
}

/* ── Large desktop ── */
@media (min-width:1600px){
  :root{--content-max:1600px;}
  .main-content{padding:2.5rem;}
}

/* ── Touch-friendly global ── */
@media (hover: none) and (pointer: coarse){
  .btn{ min-height: 44px; }
  .form-group input,
  .form-group select,
  .form-group textarea{ font-size: 16px; } /* prevent iOS zoom */
  a, button{ -webkit-tap-highlight-color: transparent; }
}

/* ── iOS notch safe areas ── */
@supports(padding: max(0px)){
  .salga-header{
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  .salga-footer{
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(.9rem, env(safe-area-inset-bottom));
  }
  .main-content{
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

/* ── Print ── */
@media print{
  .salga-header,.salga-footer,.nav,.btn,.no-print,.filters-bar{display:none!important;}
  body{background:#fff;}
  .card{box-shadow:none;border:1px solid #ccc;}
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion:reduce){
  *{animation-duration:.001s!important;transition-duration:.001s!important;}
}