/* ========================================================
   CREDIT MANAGER - GOOGLE WORKSPACE DESIGN SYSTEM
   Ultra Clean, Minimalist, Material 3 & Google Workspace UI
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&family=Roboto:wght@400;500;700&display=swap');

:root {
  /* Google Palette */
  --bg-body: #f8f9fa;
  --bg-card: #ffffff;
  --bg-subtle: #f1f3f4;
  --bg-hover: #e8eaed;
  --border-color: #dadce0;
  --border-light: #f1f3f4;
  --border-focus: #1a73e8;

  --text-main: #202124;
  --text-muted: #5f6368;
  --text-light: #80868b;

  /* Google Brand Colors */
  --google-blue: #1a73e8;
  --google-blue-hover: #1765cc;
  --google-blue-subtle: #e8f0fe;
  --google-blue-border: #aecbfa;

  --google-green: #137333;
  --google-green-subtle: #e6f4ea;
  --google-green-border: #ceead6;

  --google-yellow: #b06000;
  --google-yellow-subtle: #fef7e0;
  --google-yellow-border: #feefc3;

  --google-red: #d93025;
  --google-red-subtle: #fce8e6;
  --google-red-border: #fad2cf;

  --google-purple: #9334e6;
  --google-purple-subtle: #f3e8fd;
  --google-purple-border: #e9d5ff;

  /* Aliases for compatibility */
  --primary: var(--google-blue);
  --primary-hover: var(--google-blue-hover);
  --primary-subtle: var(--google-blue-subtle);

  --success: var(--google-green);
  --success-subtle: var(--google-green-subtle);
  --warning: var(--google-yellow);
  --warning-subtle: var(--google-yellow-subtle);
  --danger: var(--google-red);
  --danger-subtle: var(--google-red-subtle);
  --info: var(--google-blue);
  --info-subtle: var(--google-blue-subtle);

  /* Google Material Elevation Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(60, 64, 67, 0.08), 0 1px 3px 1px rgba(60, 64, 67, 0.05);
  --shadow-md: 0 1px 3px 0 rgba(60, 64, 67, 0.12), 0 4px 8px 3px rgba(60, 64, 67, 0.08);
  --shadow-lg: 0 2px 6px 2px rgba(60, 64, 67, 0.15);
  --shadow-hover: 0 2px 6px 0 rgba(60, 64, 67, 0.15), 0 1px 2px 0 rgba(60, 64, 67, 0.3);

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #f8fafc;
  color: #1e293b;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: row; /* Desktop horizontal flow (Sidebar on left, Content on right) */
  width: 100%;
}

@media (max-width: 767px) {
  body {
    flex-direction: column; /* Mobile vertical flow */
  }
}

/* Ensure hidden elements and modals never block the screen */
.hidden {
  display: none !important;
}

/* Enterprise Sidebar Layout Fixes */
#appSidebar {
  width: 16rem; /* 256px */
  background-color: #ffffff;
  border-right: 1px solid #e2e8f0;
  flex-shrink: 0;
  z-index: 50;
}

@media (min-width: 768px) {
  #appSidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transform: none !important;
  }
}

@media (max-width: 767px) {
  #appSidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
  }
  #appSidebar.-translate-x-full {
    transform: translateX(-100%);
  }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ========================================================
   TOP NAVIGATION BAR (Clean Google Workspace Style)
   ======================================================== */
.top-navbar {
  background: #ffffff;
  color: var(--text-main);
  padding: 0.65rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
  text-decoration: none;
}

.nav-brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #e8f0fe;
  color: var(--google-blue);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-text .brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #202124;
}

.brand-text .brand-badge {
  background: #f1f3f4;
  color: #5f6368;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Google Pill-Style Nav Links */
.nav-links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  list-style: none;
}

.nav-links a {
  color: #5f6368;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: var(--transition);
  text-decoration: none;
}

.nav-links a:hover {
  color: #202124;
  background: #f1f3f4;
}

.nav-links a.active {
  background: var(--google-blue-subtle);
  color: var(--google-blue);
  font-weight: 600;
}

.nav-links a svg {
  flex-shrink: 0;
}

/* Nav Actions (Right) */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-date-box {
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: #3c4043;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
}

/* ========================================================
   MAIN WRAPPER & PAGE HEADERS
   ======================================================== */
.main-wrapper {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.75rem;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #202124;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 0.2rem;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* ========================================================
   GOOGLE MATERIAL BUTTONS
   ======================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.25;
  outline: none;
}

.btn-primary, .btn-google-primary {
  background: var(--google-blue);
  color: #ffffff;
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3);
}

.btn-primary:hover, .btn-google-primary:hover {
  background: var(--google-blue-hover);
  color: #ffffff;
  box-shadow: 0 1px 3px 1px rgba(60, 64, 67, 0.15);
  transform: translateY(-0.5px);
}

.btn-success {
  background: var(--google-green);
  color: #ffffff;
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3);
}

.btn-success:hover {
  background: #0f5b28;
  color: #ffffff;
}

.btn-outline {
  background: #ffffff;
  border-color: var(--border-color);
  color: #3c4043;
}

.btn-outline:hover {
  background: #f8f9fa;
  border-color: #c6c9ce;
  color: var(--text-main);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.775rem;
  border-radius: var(--radius-sm);
}

/* ========================================================
   GOOGLE FILTER BOX & PRESETS BAR (DATE RANGE)
   ======================================================== */
.google-filter-box {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.google-filter-form {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.filter-controls-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-label-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-label-wrap .g-icon {
  color: var(--google-blue);
}

.filter-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-input-wrap .date-input {
  width: auto;
  min-width: 135px;
  padding: 0.45rem 0.65rem;
  font-size: 0.825rem;
  border-radius: var(--radius-sm);
}

.filter-input-wrap .date-sep {
  color: var(--text-muted);
  font-weight: 600;
}

.filter-presets-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.presets-label {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.2rem;
}

.preset-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: #5f6368;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.preset-chip:hover {
  background: #f1f3f4;
  color: #202124;
  border-color: #c6c9ce;
}

.preset-chip.active {
  background: var(--google-blue-subtle);
  color: var(--google-blue);
  border-color: var(--google-blue-border);
  font-weight: 600;
}

/* ========================================================
   KPI & STAT CARDS (Google Cloud / Workspace Console Look)
   ======================================================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.stat-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: #c6c9ce;
  transform: translateY(-1px);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.stat-card.blue .stat-icon { background: var(--google-blue-subtle); color: var(--google-blue); }
.stat-card.green .stat-icon { background: var(--google-green-subtle); color: var(--google-green); }
.stat-card.amber .stat-icon { background: var(--google-yellow-subtle); color: var(--google-yellow); }
.stat-card.purple .stat-icon { background: var(--google-purple-subtle); color: var(--google-purple); }
.stat-card.rose .stat-icon { background: var(--google-red-subtle); color: var(--google-red); }

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.2;
}

.stat-subtext {
  font-size: 0.785rem;
  color: var(--text-muted);
  margin-top: 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* ========================================================
   CARDS & SURFACES
   ======================================================== */
.card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.card-header {
  padding: 1rem 1.25rem;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.card-body {
  padding: 1.25rem;
}

/* Two-Column Split Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* ========================================================
   GOOGLE SHEETS / CONSOLE STYLE TABLES
   ======================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

.custom-table th {
  background: #f8f9fa;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.725rem;
  letter-spacing: 0.05em;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.custom-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  color: var(--text-main);
}

.custom-table tr:hover td {
  background: #f8f9fa;
}

.custom-table tr.total-row td {
  background: #f8f9fa;
  font-weight: 700;
  border-top: 1px solid var(--border-color);
  font-size: 0.95rem;
}

.custom-table tr.grand-total-row td {
  background: #e8f0fe;
  color: #174ea6;
  font-weight: 700;
  font-size: 1.05rem;
  border-top: 2px solid #aecbfa;
  border-bottom: 2px solid #aecbfa;
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

/* ========================================================
   REMINDERS & WIDGETS
   ======================================================== */
.reminder-card {
  border-top: 3px solid var(--google-blue);
}

.reminder-header-alert {
  background: #fef7e0;
  border-bottom: 1px solid #feefc3;
  color: #b06000;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reminder-badge-pulse {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--google-red);
  color: #ffffff;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* ========================================================
   BADGES & CHIPS (Google Material Chips)
   ======================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  line-height: 1;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success { background: var(--google-green-subtle); color: var(--google-green); border: 1px solid var(--google-green-border); }
.badge-warning { background: var(--google-yellow-subtle); color: var(--google-yellow); border: 1px solid var(--google-yellow-border); }
.badge-danger  { background: var(--google-red-subtle); color: var(--google-red); border: 1px solid var(--google-red-border); }
.badge-info    { background: var(--google-blue-subtle); color: var(--google-blue); border: 1px solid var(--google-blue-border); }
.badge-secondary { background: var(--bg-subtle); color: var(--text-muted); border: 1px solid var(--border-color); }
.badge-primary { background: var(--google-blue); color: #ffffff; }

/* Due Date Tags */
.due-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.due-overdue {
  color: var(--google-red);
  font-weight: 700;
  background: var(--google-red-subtle);
  border: 1px solid var(--google-red-border);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.due-today {
  color: var(--google-yellow);
  font-weight: 700;
  background: var(--google-yellow-subtle);
  border: 1px solid var(--google-yellow-border);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.due-soon {
  color: var(--google-blue);
  font-weight: 600;
}

/* Flash Alerts */
.alert {
  display: flex;
  align-items: center;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  gap: 0.75rem;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.alert-icon {
  font-size: 1.1rem;
  font-weight: bold;
}

.alert-text {
  flex: 1;
}

.alert-close {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
}
.alert-close:hover { opacity: 1; }

.alert-success { background: var(--google-green-subtle); border: 1px solid var(--google-green-border); color: var(--google-green); }
.alert-danger { background: var(--google-red-subtle); border: 1px solid var(--google-red-border); color: var(--google-red); }
.alert-warning { background: var(--google-yellow-subtle); border: 1px solid var(--google-yellow-border); color: var(--google-yellow); }
.alert-info { background: var(--google-blue-subtle); border: 1px solid var(--google-blue-border); color: var(--google-blue); }

/* ========================================================
   MODALS & FORMS
   ======================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(32, 33, 36, 0.6);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-backdrop.active {
  display: flex;
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-md);
  max-width: 550px;
  width: 100%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: modalSlide 0.2s ease-out;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #202124;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover {
  background: #f1f3f4;
  color: #202124;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-main);
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.18);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Search and Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  min-width: 260px;
}

.search-input-wrapper input {
  padding-left: 2.2rem;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 0.9rem;
}

/* Footer */
.app-footer {
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  margin-top: auto;
  font-size: 0.825rem;
  color: var(--text-muted);
  text-align: center;
}

/* Print Stylesheet */
@media print {
  .top-navbar, .page-header-actions, .btn, .filter-bar, .google-filter-box, .modal-backdrop, .app-footer {
    display: none !important;
  }
  body, .main-wrapper {
    background: #ffffff !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }
  .card {
    border: none !important;
    box-shadow: none !important;
  }
  .custom-table {
    border: 1px solid #000 !important;
  }
  .custom-table th, .custom-table td {
    border: 1px solid #ddd !important;
  }
}
