/* Thangavel Accounts App - Premium Financial Theme */

:root {
  --bg-primary: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-card-hover: #1e293b;
  --border-color: rgba(255, 255, 255, 0.1);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-highlight: #38bdf8;

  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-purple: #8b5cf6;
  --accent-rose: #f43f5e;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-family);
}

body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Navbar */
.navbar {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.brand-text h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text span {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  font-weight: 600;
}

.role-selector-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(30, 41, 59, 0.6);
  padding: 0.4rem 0.8rem;
  border-radius: 30px;
  border: 1px solid var(--border-color);
}

.role-badge {
  font-size: 0.8rem;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.role-badge.active {
  background: var(--accent-blue);
  color: white;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

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

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.user-role-label {
  font-size: 0.75rem;
  color: var(--accent-cyan);
}

.btn-logout {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: var(--accent-rose);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: var(--accent-rose);
  color: white;
}

/* Layout Container */
.container {
  max-width: 1300px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
  flex: 1;
  width: 100%;
}

/* Navigation Tabs */
.tabs-header {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.8rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
}

/* Interactive Clickable Cards for Contractor View */
.clickable-card {
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-color);
  position: relative;
}

.clickable-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-cyan);
  box-shadow: 0 12px 28px -5px rgba(6, 182, 212, 0.3);
}

.clickable-card.selected-card {
  border-color: var(--accent-cyan);
  background: rgba(30, 41, 59, 0.95);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.4);
}

.click-hint-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 20px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  font-weight: 600;
  margin-top: 0.5rem;
  align-self: flex-start;
}

/* Stats Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-blue);
}

.stat-card.blue::after { background: var(--accent-blue); }
.stat-card.cyan::after { background: var(--accent-cyan); }
.stat-card.green::after { background: var(--accent-green); }
.stat-card.amber::after { background: var(--accent-amber); }
.stat-card.rose::after { background: var(--accent-rose); }

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

.stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.stat-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Controls & Action Bar */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

/* Card Section */
.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

.data-table th {
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.data-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-pending { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-fulfilled { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-partial { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-available { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); border: 1px solid rgba(6, 182, 212, 0.3); }

/* Currency formatting */
.amount {
  font-family: monospace;
  font-weight: 700;
}

.amount.credit { color: var(--accent-green); }
.amount.debit {
    color: var(--accent-amber);
  }
.amount.balance { color: var(--accent-cyan); }

/* Material Category Grouping Filter Bar */
.material-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.6rem 1rem;
  margin-bottom: 1.25rem;
}

.mat-pill {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mat-pill:hover {
  background: var(--bg-card-hover);
  color: white;
  border-color: var(--accent-cyan);
}

.mat-pill.active {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  pointer-events: none;
}

.modal-overlay.active {
  display: flex;
  pointer-events: auto;
}

.modal-box {
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 540px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

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

.modal-header h3 {
  font-size: 1.1rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}

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

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  color: var(--text-main);
  font-size: 0.9rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 2rem;
}

/* Login Modal Specifics */
.login-box {
  max-width: 420px;
}

.login-demo-pills {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.demo-pill {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.demo-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent-blue);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Mobile bottom navigation */
body.has-mobile-nav {
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  background: #0a0f1e;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.35rem 0 calc(0.35rem + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.45);
}

.mbn-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.62rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.35rem 0;
  min-height: 56px;
}

.mbn-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.mobile-downloads-panel {
  position: fixed;
  bottom: calc(68px + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  z-index: 9998;
  background: #0a0f1e;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 1rem 1rem 1.2rem;
  max-height: 50vh;
  overflow-y: auto;
}

.mobile-downloads-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: white;
  margin-bottom: 0.8rem;
}

.mobile-downloads-close {
  margin-top: 0.8rem;
  width: 100%;
  padding: 0.6rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #94a3b8;
  font-weight: 700;
  cursor: pointer;
}

#mobileDownloadButtons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

@media (max-width: 900px) {
  .navbar {
    padding: 0.65rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .user-profile {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .user-profile select,
  .user-info {
    display: none;
  }

  .brand-text span {
    display: none;
  }

  .container {
    margin: 0.75rem auto;
    padding: 0 0.75rem;
  }

  .stats-grid {
    grid-template-columns: 1fr !important;
  }

  .single-page-toggle {
    flex-direction: column;
    max-width: 100% !important;
  }

  .modal-box {
    max-width: 95vw !important;
    margin: 0.5rem;
  }

  /* Reduce GPU-heavy blur on mobile to prevent hang */
  .navbar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  body {
    background-attachment: scroll;
  }
}
