/* =========================================
   1. GLOBAL & RESET
========================================= */
body {
  font-family: Arial, sans-serif;
  background-color: #f4f7f6;
  margin: 0;
  padding: 10px;
}

/* =========================================
   2. LOGIN SCREEN
========================================= */
.login-container {
  background-color: white;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  width: 90%;
  max-width: 320px;
  text-align: center;
  margin: 50px auto;
}
.login-container h2 {
  color: #2c3e50;
  margin-bottom: 20px;
}
.login-container input {
  width: 100%;
  padding: 10px;
  margin: 10px 0;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}

/* =========================================
   3. BUTTONS
========================================= */
button {
  background-color: #2980b9;
  color: white;
  padding: 10px 15px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  transition: 0.2s;
}
button:hover { background-color: #3498db; }
button:disabled { background-color: #95a5a6; cursor: not-allowed; }

.btn-danger { background-color: #e74c3c; }
.btn-danger:hover { background-color: #c0392b; }
.btn-warning { background-color: #f39c12; }
.btn-warning:hover { background-color: #e67e22; }

/* =========================================
   4. APP LAYOUT & NAVIGATION
========================================= */
.app-container {
  display: none; /* Hidden until user logs in */
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}
.card {
  background-color: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}
.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #2c3e50;
  padding-bottom: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.nav-buttons button {
  background-color: #7f8c8d;
  margin-right: 5px;
  margin-bottom: 5px;
}
.nav-buttons button.active {
  background-color: #2c3e50;
}

/* =========================================
   5. DASHBOARD SUMMARY & FORMS
========================================= */
.summary-container {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.summary-box {
  flex: 1;
  padding: 15px;
  border-radius: 8px;
  color: white;
  text-align: center;
  min-width: 250px;
}
.cash-bg { background-color: #27ae60; }
.bank-bg { background-color: #2980b9; }

.entry-form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.entry-form-row > * {
  flex: 1 1 120px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}
.entry-form-row > input[type="text"]:nth-child(2) {
  flex: 3 1 200px; /* Makes the Particulars input wider */
}

/* =========================================
   6. STANDARD TABLES (Dashboard & Admin)
========================================= */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
  min-width: 800px;
}
th {
  background-color: #2c3e50;
  color: white;
  padding: 10px;
  border: 1px solid #ddd;
}
td {
  padding: 8px;
  border: 1px solid #ddd;
}
.bal-col {
  font-weight: bold;
  background-color: #f9f9f9;
}

/* =========================================
   7. T-FORMAT REPORT (BULLETPROOF GRID)
========================================= */
.folio-container { 
  display: grid; 
  grid-template-columns: 1fr 1fr; /* Creates an unbreakable 50/50 wall */
  width: 100%; 
  border: 2px solid #000; 
  background-color: #fff;
}
.folio-side { 
  width: 100%; 
  max-width: 100%;
  overflow: hidden; 
}
.folio-side.left { 
  border-right: 2px solid #000; 
}
.folio-header { 
  text-align: center; 
  font-weight: bold; 
  font-size: 14px; 
  padding: 8px; 
  border-bottom: 2px solid #000; 
  background-color: #f0f0f0; 
}

/* Force the tables inside the grid to strictly obey widths */
.folio-table { 
  width: 100%; 
  border-collapse: collapse; 
  table-layout: fixed; 
  min-width: 0 !important; /* <--- THIS IS THE MAGIC FIX */
}
.folio-table th, .folio-table td { 
  border: 1px solid #000; 
  padding: 4px; 
  font-size: 11px; 
  overflow-wrap: break-word; /* Wrap long text instead of stretching */
  word-wrap: break-word;
}
.folio-table th { 
  background-color: #e0e0e0; 
  color: #000;
  text-align: center; 
}

/* Strict Column Widths for the Report (Totals 100%) */
.col-date { width: 16%; }
.col-part { width: 34%; }
.col-vch  { width: 14%; }
.col-cash { width: 18%; }
.col-bank { width: 18%; }

.amount-col { text-align: right; }
.closing-row { font-weight: bold; font-style: italic; background-color: #fafafa; }
.total-row { font-weight: bold; font-size: 12px; background-color: #e0e0e0; }

/* =========================================
   8. RESPONSIVE / MOBILE SCREENS
========================================= */
@media (max-width: 768px) {
  .folio-container { 
    grid-template-columns: 1fr; /* Stack Receipts on top of Payments on phones */
  }
  .folio-side.left { 
    border-right: none; 
    border-bottom: 2px solid #000; 
  }
  .entry-form-row > * { 
    flex: 1 1 100%; /* Stack the data entry inputs */
  }
}

/* =========================================
   9. PRINT & PDF RULES
========================================= */
@media print { 
  body, .app-container, .card { 
    background: white; 
    margin: 0; 
    padding: 0; 
    box-shadow: none; 
    border: none; 
  } 
  
  /* NEW: Exempts BOTH the Folio Report and the Account Statement from being hidden */
  .nav-bar, .no-print, .card:not(#report-print-area):not(#stmt-print-area) { 
    display: none !important; 
  } 
  
  #report-print-area, #stmt-print-area { 
    padding: 0; 
    margin: 0; 
  }
}
