/* ==========================================
   PREMIUM BILLING SOFTWARE STYLESHEET
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* Zoho Color System */
  --primary: 207, 90%, 39%;     /* Zoho Blue */
  --primary-dark: 207, 90%, 31%;
  --secondary: 220, 13%, 18%;   /* Zoho dark slate */
  --accent: 142, 60%, 40%;      /* Zoho Green */
  --bg-app: 220, 14%, 96%;       /* Zoho light background gray #f3f4f6 */
  --bg-card: 0, 0%, 100%;
  --border-color: 220, 13%, 91%; /* Fine border #e5e7eb */
  --text-main: 220, 30%, 15%;
  --text-muted: 220, 12%, 50%;
  
  --primary-color: hsl(var(--primary));
  --primary-dark-color: hsl(var(--primary-dark));
  --secondary-color: hsl(var(--secondary));
  --accent-color: hsl(var(--accent));
  --bg-app-color: hsl(var(--bg-app));
  --bg-card-color: hsl(var(--bg-card));
  --border-color-val: hsl(var(--border-color));
  --text-main-color: hsl(var(--text-main));
  --text-muted-color: hsl(var(--text-muted));

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-app-color);
  color: var(--text-main-color);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--text-main-color);
  margin-top: 0;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: hsl(var(--primary), 30%);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* ==========================================
   APP LAYOUT (Sidebar & Main Section)
   ========================================== */

#app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

#sidebar {
  width: 240px;
  background: #ffffff;
  color: #334155;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  border-right: 1px solid #eaedf1;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar .logo-section {
  padding: 14px 20px;
  border-bottom: 1px solid #eaedf1;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  box-sizing: border-box;
  flex-shrink: 0;
}

#sidebar .logo-text {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 800;
  color: #1e293b;
}

#sidebar .nav-menu {
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-grow: 1;
  overflow-y: auto;
}

#sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 4px;
  color: #475569;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: all 0.15s ease;
}

#sidebar .nav-item i {
  width: 18px;
  text-align: center;
  font-size: 15px;
  color: #64748b;
}

#sidebar .nav-item:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

#sidebar .nav-item:hover i {
  color: #0f172a;
}

#sidebar .nav-item.active {
  color: #ea580c;
  background-color: #fff7ed;
  font-weight: 600;
}

#sidebar .nav-item.active i {
  color: #ea580c;
}

#sidebar .user-profile {
  padding: 12px 20px;
  border-top: 1px solid #eaedf1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #f8fafc;
  flex-shrink: 0;
}

#sidebar .user-info {
  display: flex;
  flex-direction: column;
}

#sidebar .user-name {
  font-weight: 600;
  font-size: 13px;
  color: #1e293b;
}

#sidebar .user-role {
  font-size: 11px;
  color: #64748b;
}

#content-wrapper {
  margin-left: 240px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Sidebar Collapsed / Toggle State ── */
#app-container.sidebar-collapsed #sidebar {
  width: 68px !important;
}
#app-container.sidebar-collapsed #sidebar .logo-text,
#app-container.sidebar-collapsed #sidebar .user-info,
#app-container.sidebar-collapsed #sidebar .fa-chevron-down,
#app-container.sidebar-collapsed #sidebar .collapse,
#app-container.sidebar-collapsed #sidebar .user-profile span {
  display: none !important;
}

#app-container.sidebar-collapsed #sidebar .logo-section {
  padding: 12px 0 !important;
  justify-content: center !important;
}

#app-container.sidebar-collapsed #sidebar .nav-item {
  font-size: 0 !important;
  justify-content: center !important;
  padding: 12px 0 !important;
  gap: 0 !important;
  text-align: center !important;
}

#app-container.sidebar-collapsed #sidebar .nav-item i {
  font-size: 18px !important;
  margin: 0 !important;
  width: auto !important;
}

#app-container.sidebar-collapsed #sidebar .user-profile {
  padding: 12px 0 !important;
  justify-content: center !important;
}

#app-container.sidebar-collapsed #sidebar .user-profile a {
  font-size: 0 !important;
  padding: 6px 10px !important;
}

#app-container.sidebar-collapsed #sidebar .user-profile a i {
  font-size: 15px !important;
  margin: 0 !important;
}

#app-container.sidebar-collapsed #content-wrapper {
  margin-left: 68px !important;
}

@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #content-wrapper {
    margin-left: 0 !important;
  }
  #app-container.sidebar-collapsed #sidebar {
    transform: translateX(0);
    width: 240px;
  }
}

#topbar {
  height: 56px;
  background-color: #1e293b;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 99;
}

#main-content {
  padding: 24px;
  flex-grow: 1;
  background-color: #f4f5f8;
}

/* ==========================================
   CARDS & PANELS (Modern Glassmorphism)
   ========================================== */

.glass-card {
  background-color: var(--bg-card-color);
  border: 1px solid var(--border-color-val);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: all 0.3s ease;
}

.glass-card:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(15, 117, 188, 0.2);
}

.kpi-card {
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background-color: var(--primary-color);
}

.kpi-card.kpi-sales::before { background-color: var(--primary-color); }
.kpi-card.kpi-collected::before { background-color: var(--accent-color); }
.kpi-card.kpi-outstanding::before { background-color: #ef4444; }

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-heading);
  margin-top: 8px;
}

/* ==========================================
   FORM CONTROLS (Elegant and clean)
   ========================================== */

.form-control, .form-select {
  border: 1px solid var(--border-color-val);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  background-color: #f8fafc;
  color: var(--text-main-color);
  transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
  background-color: #fff;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(15, 117, 188, 0.15);
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark-color) 100%);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(15, 117, 188, 0.2);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(15, 117, 188, 0.3);
}

/* ==========================================
   SPLIT-SCREEN INVOICE DESIGNER
   ========================================== */

.split-container {
  display: flex;
  gap: 24px;
  height: calc(100vh - 160px);
}

.split-left {
  flex: 1.1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  padding-right: 8px;
}

.split-right {
  flex: 0.9;
  overflow-y: auto;
  position: sticky;
  top: 94px;
  background-color: #475569;
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.1);
  display: flex;
  justify-content: center;
}

/* Dynamic Live Invoice Template */
.invoice-sheet {
  width: 100%;
  max-width: 800px;
  min-height: 842px; /* A4 Ratio */
  background-color: #ffffff;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  border-radius: 4px;
  color: #1e293b;
  display: flex;
  flex-direction: column;
  font-size: 13px;
  line-height: 1.5;
}

.invoice-sheet .invoice-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.invoice-sheet .company-details h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: #0f172a;
}

.invoice-sheet .company-details p, .invoice-sheet .bill-to p {
  margin: 0 0 4px 0;
  color: #475569;
}

.invoice-sheet .invoice-title {
  text-align: right;
}

.invoice-sheet .invoice-title h1 {
  font-size: 26px;
  font-weight: 800;
  color: #6366f1;
  margin: 0 0 10px 0;
  text-transform: uppercase;
}

.invoice-sheet .bill-to h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 8px 0;
  color: #0f172a;
  text-transform: uppercase;
}

.invoice-sheet .invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 24px;
}

.invoice-sheet .invoice-table th {
  background-color: #f8fafc;
  border-bottom: 2px solid #cbd5e1;
  padding: 10px 8px;
  text-align: left;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  font-size: 11px;
}

.invoice-sheet .invoice-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 12px 8px;
  color: #334155;
}

.invoice-sheet .summary-section {
  display: flex;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 30px;
}

.invoice-sheet .notes-block {
  width: 50%;
}

.invoice-sheet .notes-block h4 {
  font-size: 12px;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: #0f172a;
}

.invoice-sheet .notes-block p {
  margin: 0;
  color: #64748b;
  font-size: 12px;
}

.invoice-sheet .total-block {
  width: 40%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.invoice-sheet .total-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #475569;
}

.invoice-sheet .total-row.grand-total {
  border-top: 2px solid #cbd5e1;
  padding-top: 10px;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

/* ==========================================
   PRINT-ONLY STYLES
   ========================================== */

@media print {
  body {
    background-color: #fff !important;
    color: #000 !important;
  }
  #sidebar, #topbar, .btn, .split-left, .split-right {
    display: none !important;
  }
  #content-wrapper {
    margin-left: 0 !important;
  }
  #main-content {
    padding: 0 !important;
  }
  .invoice-sheet {
    box-shadow: none !important;
    padding: 0 !important;
    border: none !important;
    min-height: auto !important;
  }
}