@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Noto+Sans+Gujarati:wght@400;500;600;700&display=swap');

/* ==========================================================================
   DEVANGI SEWING CLASSES — DESIGN SYSTEM TOKENS
   Royal Purple & Dark Navy Architecture
   ========================================================================== */
:root {
  /* Brand Palette */
  --primary: #6D5CE7;
  --primary-hover: #5B4BD8;
  --primary-light: #F0EDFF;
  --navy: #111827;
  --navy-light: #1F2937;
  
  /* Neutral Surfaces & Text */
  --bg: #F5F7FA;
  --card-bg: #FFFFFF;
  --sidebar-bg: #111827;
  --sidebar-active: #1F2937;
  --text: #1F2937;
  --muted: #64748B;
  --border: #E2E8F0;
  --border-light: #F1F5F9;
  --border-input: #CBD5E1;
  --hover-bg: #F0EDFF;
  
  /* Semantic Status Palette */
  --success: #16A34A;
  --success-hover: #15803D;
  --success-bg: #F0FDF4;
  --success-border: #BBF7D0;
  
  --warning: #D97706;
  --warning-hover: #B45309;
  --warning-bg: #FFFBEB;
  --warning-border: #FDE68A;
  
  --danger: #DC2626;
  --danger-hover: #B91C1C;
  --danger-bg: #FEF2F2;
  --danger-border: #FECACA;
  
  /* Shadows & Radii */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', 'Noto Sans Gujarati', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--primary-hover);
}

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

/* ==========================================================================
   SIDEBAR & BRAND
   ========================================================================== */
.sidebar {
  width: 244px;
  background: var(--sidebar-bg);
  color: #FFFFFF;
  padding: 0 0 24px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  font-weight: 700;
  font-size: 16px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid #1F2937;
  letter-spacing: -0.01em;
  color: #FFFFFF;
}

.sidebar .brand span {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: #94A3B8;
  margin-top: 2px;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
}

.sidebar nav a {
  color: #94A3B8;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar nav a svg {
  flex-shrink: 0;
  color: #94A3B8;
  transition: color 0.15s ease;
}

.sidebar nav a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #F8FAFC;
}

.sidebar nav a:hover svg {
  color: #F8FAFC;
}

.sidebar nav a.active {
  background: var(--sidebar-active);
  color: #FFFFFF;
  font-weight: 600;
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.sidebar nav a.active svg {
  color: #FFFFFF;
}

/* ==========================================================================
   TOPBAR & HEADER
   ========================================================================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
}

.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.user-menu span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-weight: 600;
}

.user-menu small {
  color: var(--secondary);
  font-weight: 500;
  background: #F1F5F9;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 11.5px;
}

.btn-link {
  color: var(--muted);
  font-weight: 500;
  background: #FFFFFF;
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: var(--radius);
  font-size: 12.5px;
  transition: all 0.15s ease;
}

.btn-link:hover {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}

.content {
  padding: 24px 28px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   FLASH ALERTS
   ========================================================================== */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
}

.flash-success {
  background: var(--success-bg);
  color: #166534;
  border-color: var(--success-border);
}

.flash-error, .flash-danger {
  background: var(--danger-bg);
  color: #991B1B;
  border-color: var(--danger-border);
}

.flash-warning {
  background: var(--warning-bg);
  color: #92400E;
  border-color: var(--warning-border);
}

.flash-info {
  background: var(--primary-light);
  color: var(--primary);
  border-color: #DDD6FE;
}

/* ==========================================================================
   SURFACES, CARDS & PANELS
   ========================================================================== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.card h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ==========================================================================
   STATISTICS & KPI CARDS
   ========================================================================== */
.grid {
  display: grid;
  gap: 16px;
}

.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 1024px) {
  .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

.kpi {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi .num {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.kpi .label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 4px;
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.kpi-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  background: #F8FAFC;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

/* ==========================================================================
   SEGMENTED CONTROLS & TABS
   ========================================================================== */
.view-mode-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.view-mode-item {
  padding: 7px 16px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FFFFFF;
  color: var(--muted);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}

.view-mode-item:hover {
  color: var(--text);
  background: var(--hover-bg);
  border-color: #DDD6FE;
}

.view-mode-item.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  font-weight: 600;
}

.batch-tab-bar {
  background: #F1F5F9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  display: inline-flex;
  gap: 3px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 18px;
}

.batch-tab-item {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.15s ease;
  display: inline-block;
}

.batch-tab-item:hover {
  color: var(--text);
}

.batch-tab-item.active {
  background: #FFFFFF;
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: #F1F5F9;
  padding: 3px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  width: fit-content;
  flex-wrap: wrap;
}

.tabs a {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.tabs a:hover {
  color: var(--text);
}

.tabs a.active {
  background: #FFFFFF;
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* ==========================================================================
   TABLES
   ========================================================================== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

th {
  background: #F8FAFC;
  color: #475569;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #F8FAFC;
}

/* ==========================================================================
   BADGES & STATUS PILLS
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0;
  border: 1px solid transparent;
}

.badge-green { background: var(--success-bg); color: #166534; border-color: var(--success-border); }
.badge-amber { background: var(--warning-bg); color: #92400E; border-color: var(--warning-border); }
.badge-red { background: var(--danger-bg); color: #991B1B; border-color: var(--danger-border); }
.badge-gray { background: #F1F5F9; color: var(--muted); border-color: var(--border); }
.badge-purple { background: var(--primary-light); color: var(--primary); border-color: #DDD6FE; }

/* ==========================================================================
   FORMS & INPUT CONTROLS
   ========================================================================== */
form label {
  display: block;
  font-size: 13px;
  color: #374151;
  margin: 10px 0 5px;
  font-weight: 600;
}

form input[type=text],
form input[type=email],
form input[type=tel],
form input[type=number],
form input[type=date],
form input[type=password],
form select,
form textarea {
  width: 100%;
  height: 38px;
  padding: 8px 12px;
  background: #FFFFFF;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow-xs);
}

form textarea {
  height: auto;
  min-height: 80px;
}

form input:focus,
form select:focus,
form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(109, 92, 231, 0.12);
}

/* ==========================================================================
   FORM GRIDS & ACTIONS
   ========================================================================== */
.row, form.row, form .row { 
  display: grid; 
  grid-template-columns: repeat(2, 1fr); 
  gap: 16px; 
  align-items: flex-end;
}

.row3, form.row3, form .row3 { 
  display: grid; 
  grid-template-columns: repeat(3, 1fr); 
  gap: 16px; 
  align-items: flex-end;
}

.row4, form.row4, form .row4 { 
  display: grid; 
  grid-template-columns: repeat(4, 1fr); 
  gap: 16px; 
  align-items: flex-end;
}

/* Dedicated responsive filter row for search bars & filters */
.filter-row, form.filter-row {
  display: grid;
  grid-template-columns: 2fr 1.5fr auto;
  gap: 16px;
  align-items: flex-end;
}

/* Flexible filter forms with wrap */
.filter-form, form.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.filter-form > div {
  flex: 1 1 180px;
  min-width: 160px;
}

.filter-form > div.form-actions {
  flex: 0 0 auto;
}

/* Form actions / button container: ensures buttons never glue to text boxes */
.form-actions,
.row > div.form-actions,
.row3 > div.form-actions,
.row4 > div.form-actions,
.filter-row > div.form-actions,
.filter-form > div.form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 38px;
}

/* Default spacing when buttons are placed in stacked/block forms directly */
form > .form-actions,
form > .btn,
form > button[type="submit"],
.form-btn-group {
  margin-top: 16px;
}

/* Responsive breakdowns for grid forms */
@media (max-width: 900px) {
  .row3, form.row3, form .row3,
  .row4, form.row4, form .row4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .filter-row, form.filter-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .row, form.row, form .row,
  .row3, form.row3, form .row3,
  .row4, form.row4, form .row4,
  .filter-row, form.filter-row {
    grid-template-columns: 1fr;
  }
  .row > div.form-actions,
  .row3 > div.form-actions,
  .row4 > div.form-actions,
  .filter-row > div.form-actions,
  .row > div:last-child,
  .row3 > div:last-child,
  .row4 > div:last-child,
  .filter-row > div:last-child {
    margin-top: 8px;
  }
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  background: var(--primary);
  color: #FFFFFF;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-xs);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--primary-hover);
  color: #FFFFFF;
}

.btn-secondary {
  background: #FFFFFF;
  color: #374151;
  border: 1px solid var(--border-input);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background: #F8FAFC;
  border-color: #94A3B8;
  color: var(--text);
}

.btn-success {
  background: var(--success);
  color: #FFFFFF;
}

.btn-success:hover {
  background: var(--success-hover);
  color: #FFFFFF;
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}

.btn-danger:hover {
  background: var(--danger-hover);
  color: #FFFFFF;
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}

.btn-export {
  background: var(--success);
  color: #FFFFFF;
  border: none;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
}

.btn-export:hover {
  background: var(--success-hover);
  color: #FFFFFF;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 20px 0 10px;
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.custom-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(2px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.custom-modal {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  border: 1px solid var(--border);
}

.custom-modal-header {
  padding: 16px 20px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.custom-modal-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.custom-modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.custom-modal-close:hover {
  color: var(--text);
}

.custom-modal-body {
  padding: 20px;
}

.custom-modal-footer {
  padding: 12px 20px;
  background: #F8FAFC;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   LOGIN SCREEN
   ========================================================================== */
.login-wrap {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: #F5F7FA;
}

.login-card {
  background: #FFFFFF;
  padding: 36px 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}

.login-card p {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 20px;
}

.muted { color: var(--muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }

/* ==========================================================================
   PRINT LAYOUT
   ========================================================================== */
@media print {
  .sidebar, .topbar, .actions-bar, form, button, .btn, .no-print {
    display: none !important;
  }
  .app-shell {
    display: block !important;
    min-height: auto !important;
  }
  .main, .content {
    padding: 0 !important;
    margin: 0 !important;
  }
  .card {
    border: 1px solid #CCC !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }
}
