
/* Sagara CRM — modern responsive UI layer
   Frontend-only: no business logic, database, or endpoint changes. */
:root{
  --ui-bg:#f5f7fb;
  --ui-surface:#ffffff;
  --ui-border:#e5e7eb;
  --ui-text:#111827;
  --ui-muted:#64748b;
  --ui-primary:#111827;
  --ui-accent:#f59e0b;
  --ui-radius:16px;
  --ui-shadow:0 8px 30px rgba(15,23,42,.07);
}
html{scroll-behavior:smooth;}
body{
  background:var(--ui-bg);
  color:var(--ui-text);
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}
button,a,input,select,textarea{ -webkit-tap-highlight-color:transparent; }
button{touch-action:manipulation;}
input,select,textarea{font-size:16px;}
img{max-width:100%;}

/* Sidebar */
#sidebar{
  background:linear-gradient(180deg,#111827 0%,#0b1220 100%) !important;
  border-right:1px solid rgba(255,255,255,.06);
  box-shadow:8px 0 30px rgba(15,23,42,.08);
}
#sidebar h1{letter-spacing:-.02em;}
#sidebar ul a{
  display:flex;
  align-items:center;
  min-height:42px;
  padding:9px 11px;
  border-radius:11px;
  color:#cbd5e1;
  transition:background .18s ease,color .18s ease,transform .18s ease;
}
#sidebar ul a:hover{
  background:rgba(255,255,255,.07);
  color:#fff;
  transform:translateX(2px);
}
#sidebar ul a.text-yellow-300{
  background:rgba(245,158,11,.14);
  color:#fbbf24 !important;
}
#menuBtn{
  width:44px;height:44px;
  display:flex;align-items:center;justify-content:center;
  border:1px solid rgba(15,23,42,.08);
  background:#111827 !important;
  box-shadow:0 8px 22px rgba(15,23,42,.18);
}
#overlay{backdrop-filter:blur(2px);}

/* Shared surfaces */
main .bg-white,
.flex-1 > .bg-white,
.flex-1 .shadow,
.flex-1 .shadow-sm{
  border-color:var(--ui-border);
}
.flex-1 .shadow,
.flex-1 .shadow-sm{
  box-shadow:var(--ui-shadow);
}
.flex-1 .rounded,
.flex-1 .rounded-lg,
.flex-1 .rounded-xl{
  border-radius:var(--ui-radius);
}

/* Controls */
input:not([type=checkbox]):not([type=radio]),
select,textarea{
  border-color:#dbe2ea;
  border-radius:11px;
  transition:border-color .18s,box-shadow .18s,background .18s;
}
input:not([type=checkbox]):not([type=radio]):focus,
select:focus,textarea:focus{
  outline:none;
  border-color:#94a3b8;
  box-shadow:0 0 0 4px rgba(59,130,246,.09);
}
button{
  border-radius:11px;
  transition:transform .12s ease,box-shadow .18s ease,opacity .18s ease;
}
button:active{transform:translateY(1px);}

/* Tables become scrollable without changing their content */
table{border-collapse:separate;border-spacing:0;}
.overflow-x-auto{
  -webkit-overflow-scrolling:touch;
  scrollbar-width:thin;
}
table thead th{white-space:nowrap;}
table tbody td{vertical-align:middle;}

/* Cards */
[class*="grid"] > .bg-white{
  border:1px solid var(--ui-border);
}

/* Toast / dialogs */
.fixed.inset-0{overscroll-behavior:contain;}
[role="dialog"]{max-height:calc(100dvh - 24px);overflow:auto;}

@media (max-width:1023px){
  #sidebar{
    width:min(82vw,310px) !important;
    padding:18px !important;
  }
  .lg\:static{position:fixed !important;}
  .lg\:flex{display:flex !important;}
  .lg\:translate-x-0{transform:translateX(-100%) !important;}
  #sidebar.translate-x-0{transform:translateX(0) !important;}
  #sidebar.-translate-x-full{transform:translateX(-100%) !important;}
  #sidebar.translate-x-0{box-shadow:18px 0 45px rgba(15,23,42,.28);}
  .flex-1{min-width:0;}
}

@media (max-width:767px){
  body{min-width:320px;}
  .flex-1{
    width:100%;
    padding-left:16px !important;
    padding-right:16px !important;
    padding-top:68px !important;
    padding-bottom:24px !important;
  }
  .flex-1 > .flex.justify-between,
  .flex-1 > div.flex.justify-between{
    gap:12px;
    flex-wrap:wrap;
  }
  h1{line-height:1.15;}
  h2{line-height:1.2;}

  /* Tailwind two-column layouts collapse to one column on phones */
  .grid.grid-cols-2,
  .grid.md\:grid-cols-2,
  .grid.lg\:grid-cols-2{
    grid-template-columns:minmax(0,1fr) !important;
  }
  .col-span-2,.md\:col-span-2,.lg\:col-span-2{
    grid-column:span 1 / span 1 !important;
  }

  /* Header action groups */
  .flex.justify-between{
    align-items:flex-start;
  }
  .flex.justify-between > .flex.gap-2,
  .flex.justify-between > .flex.gap-3{
    width:100%;
    flex-wrap:wrap;
  }
  .flex.justify-between > .flex.gap-2 > button,
  .flex.justify-between > .flex.gap-3 > button{
    flex:1 1 120px;
  }

  /* Forms */
  form.grid{gap:14px !important;}
  form.bg-white{padding:16px !important;}
  textarea{min-height:92px;}

  /* Prevent wide reports from breaking viewport */
  .overflow-x-auto, .overflow-auto{
    max-width:100%;
    overflow-x:auto;
  }

  /* Make action rows wrap */
  .flex.gap-2,.flex.gap-3,.flex.gap-4{flex-wrap:wrap;}

  /* KPI cards */
  [class*="grid-cols-4"],
  [class*="grid-cols-3"]{
    grid-template-columns:1fr !important;
  }

  /* Charts */
  canvas{max-width:100% !important;}

  /* Modal */
  .fixed.inset-0 > .w-full{
    width:calc(100vw - 24px) !important;
    max-width:none !important;
    max-height:calc(100dvh - 24px);
    overflow:auto;
  }

  /* Comfortable touch targets */
  button, a{min-height:40px;}
  #sidebar a{min-height:44px;}
}

@media (max-width:480px){
  .flex-1{padding-left:12px !important;padding-right:12px !important;}
  #menuBtn{top:12px !important;left:12px !important;}
  .text-2xl{font-size:1.35rem !important;}
  .text-3xl{font-size:1.55rem !important;}
  .text-4xl{font-size:1.85rem !important;}
  .p-6{padding:16px !important;}
  .p-5{padding:16px !important;}
  .px-6{padding-left:16px !important;padding-right:16px !important;}
  .py-6{padding-top:16px !important;padding-bottom:16px !important;}
}

/* Reduced motion */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{scroll-behavior:auto !important;transition:none !important;}
}

@media (max-width: 767px) {
    body > .flex.min-h-screen > .flex-1 {
        padding-top: 8px !important;
        margin-top: 0 !important;
    }
}
