/* 
  Khata Book Dashboard CSS 
  Theme: Dark Premium Glassmorphism
*/

:root {
  /* Color Palette */
  --bg-primary: #0f172a;
  /* Deep Slate */
  --bg-secondary: #1e293b;
  /* Darker Slate */
  --bg-tertiary: #334155;
  /* Lighter State */

  --text-main: #f8fafc;
  /* Off white */
  --text-muted: #94a3b8;
  /* Slate Gray */

  --accent-primary: #6366f1;
  /* Indigo/Neon Blue */
  --accent-hover: #4f46e5;

  --color-credit: #ef4444;
  /* Crimson Red (You Gave/Credit) */
  --color-debit: #10b981;
  /* Emerald Green (You Got/Debit) */

  /* Glassmorphism */
  --glass-bg: rgba(30, 41, 59, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

  /* Typography */
  --font-sans: 'Inter', sans-serif;
  --font-display: 'Outfit', sans-serif;

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 80px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset & Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body.dark-theme {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4,
.brand-logo h2 {
  font-family: var(--font-display);
  font-weight: 600;
}

a {
  text-decoration: none;
  color: inherit;
}

ul {
  list-style: none;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
  outline: none;
}

input {
  font-family: inherit;
  outline: none;
}

/* Utilities */
.text-credit {
  color: var(--color-credit) !important;
}

.text-debit {
  color: var(--color-debit) !important;
}

.text-right {
  text-align: right;
}

.glassmorphism {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--radius-lg);
}

/* App Layout Setup */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Mobile helpers */
.d-mobile {
  display: none;
}

/* =========================================
   Sidebar Styling
   ========================================= */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal);
  z-index: 100;
  height: 100%;
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--glass-border);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.brand-logo h2 {
  font-size: 20px;
  letter-spacing: 0.5px;
}

.brand-logo span {
  color: var(--accent-primary);
}

.sidebar-nav {
  flex: 1;
  padding: 24px 16px;
  overflow-y: auto;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-link i {
  font-size: 20px;
}

.nav-link:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-main);
  transform: translateX(4px);
}

.nav-item.active .nav-link {
  background-color: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
  border-left: 3px solid var(--accent-primary);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-top: 8px;
}

.avatar img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-primary);
}

.user-info .name {
  font-size: 14px;
  font-weight: 600;
}

.user-info .role {
  font-size: 12px;
  color: var(--text-muted);
}

/* =========================================
   Main Area & Header
   ========================================= */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.05), transparent 50%),
    radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.05), transparent 50%);
  min-width: 0;
  /* Important for flex children to allow text truncation */
}

.top-header {
  height: var(--header-height);
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title {
  font-size: 24px;
  margin-bottom: 2px;
}

.date-display {
  font-size: 13px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.search-bar {
  display: flex;
  align-items: center;
  background-color: var(--bg-secondary);
  border-radius: 20px;
  padding: 8px 16px;
  width: 250px;
  border: 1px solid var(--glass-border);
  transition: border-color var(--transition-fast);
}

.search-bar:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.search-bar i {
  color: var(--text-muted);
  font-size: 18px;
  margin-right: 8px;
}

.search-bar input {
  background: transparent;
  border: none;
  color: var(--text-main);
  width: 100%;
  font-size: 14px;
}

/* Buttons */
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all var(--transition-fast);
  position: relative;
  border: 1px solid var(--glass-border);
}

.icon-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-main);
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 8px;
  height: 8px;
  background-color: var(--color-credit);
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  transition: all var(--transition-fast);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background-color: transparent;
  color: var(--text-main);
  border: 1px solid var(--glass-border);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background-color: var(--bg-tertiary);
}

.btn-text {
  color: var(--accent-primary);
  font-weight: 500;
  font-size: 14px;
}

.btn-text:hover {
  text-decoration: underline;
}

/* =========================================
   Dashboard Content & Cards
   ========================================= */
.dashboard-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
}

.card {
  padding: 24px;
  display: flex;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-normal);
}

.card:hover {
  transform: translateY(-5px);
}

.card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  z-index: 0;
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-right: 16px;
  z-index: 1;
}

.balance-card .card-icon {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
}

.credit-card .card-icon {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-credit);
}

.debit-card .card-icon {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-debit);
}

.card-info {
  flex: 1;
  z-index: 1;
}

.card-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.card-value {
  font-size: 28px;
  line-height: 1.2;
}

.card-trend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 20px;
  z-index: 1;
}

.card-trend.positive {
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-debit);
}

.card-trend.negative {
  background: rgba(239, 68, 68, 0.15);
  color: var(--color-credit);
}

/* =========================================
   Transactions Table
   ========================================= */
.transactions-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-header h2 {
  font-size: 20px;
}

.filters {
  display: flex;
  gap: 8px;
  background-color: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
}

.filter-btn {
  padding: 6px 16px;
  font-size: 13px;
  border-radius: 4px;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.filter-btn.active,
.filter-btn:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-main);
}

.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

.data-table th,
.data-table td {
  padding: 16px 24px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.data-table th {
  font-weight: 500;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(15, 23, 42, 0.4);
}

.data-table tbody tr {
  transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.data-table td {
  font-size: 14px;
}

.td-date {
  color: var(--text-muted);
}

.td-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}

.td-user .icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.td-amount {
  font-weight: 600;
  font-family: var(--font-display);
}

.action-btns {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Empty State */
.empty-state td {
  padding: 60px 24px;
  text-align: center;
}

.empty-state-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
}

.empty-state-content i {
  font-size: 48px;
  opacity: 0.5;
  margin-bottom: 8px;
}

/* =========================================
   Modal Form Styles
   ========================================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  width: 90%;
  max-width: 500px;
  transform: translateY(20px);
  transition: all var(--transition-normal);
  padding: 32px;
  background: var(--bg-secondary);
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-header h2 {
  font-size: 22px;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Radio Selection Cards */
.txn-type-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 8px;
}

.radio-card {
  position: relative;
  cursor: pointer;
}

.radio-card input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.radio-card .card-content {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
  background: rgba(255, 255, 255, 0.02);
}

.radio-card .card-content i {
  font-size: 24px;
}

.radio-card.debit input:checked~.card-content {
  border-color: var(--color-debit);
  background: rgba(16, 185, 129, 0.1);
}

.radio-card.debit input:checked~.card-content i,
.radio-card.debit input:checked~.card-content span {
  color: var(--color-debit);
}

.radio-card.credit input:checked~.card-content {
  border-color: var(--color-credit);
  background: rgba(239, 68, 68, 0.1);
}

.radio-card.credit input:checked~.card-content i,
.radio-card.credit input:checked~.card-content span {
  color: var(--color-credit);
}

/* Generic Form Fields */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 14px;
  color: var(--text-muted);
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon i {
  position: absolute;
  left: 16px;
  color: var(--text-muted);
  font-size: 18px;
}

.input-with-icon input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 16px 14px 44px;
  color: var(--text-main);
  font-size: 16px;
  transition: all var(--transition-fast);
}

.input-with-icon input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Chrome, Safari, Edge, Opera num arrows hide */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 12px;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-entry {
  animation: fadeInUp 0.4s ease forwards;
}

/* =========================================
   Responsive Design
   ========================================= */
@media (max-width: 1024px) {
  .dashboard-scroll {
    padding: 24px;
  }

  .summary-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .d-mobile {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
  }

  .top-header {
    padding: 0 20px;
  }

  #addTxnBtnHeader,
  .search-bar {
    display: none;
    /* Hide large elements on mobile header */
  }

  .summary-cards {
    grid-template-columns: 1fr;
  }

  .fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    z-index: 90;
    transition: transform 0.2s;
  }

  .fab:active {
    transform: scale(0.95);
  }
}

/* =========================================
   Views & Tab System
   ========================================= */
.views-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.page-view {
  display: none;
  flex: 1;
  flex-direction: column;
  height: 100%;
  animation: fadeIn 0.3s ease forwards;
}

.page-view.active {
  display: flex;
}

.placeholder-section {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 400px;
}

.placeholder-card {
  text-align: center;
  padding: 40px;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.display-icon {
  font-size: 64px;
  color: var(--accent-primary);
  opacity: 0.8;
  margin-bottom: 8px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}