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

:root {
  --bg-primary: #03110D;
  --bg-secondary: #03110D;
  --bg-card: #16302B;
  --text-primary: #E0E0E0;
  --text-secondary: rgba(224, 224, 224, 0.6);
  --accent-gold: #A38560;
  --accent-gold-hover: #390517;
  --border-color: rgba(163, 133, 96, 0.2);
  --input-bg: rgba(3, 17, 13, 0.5);
  --font-serif: 'Playfair Display', serif;
  --font-sans: 'Inter', sans-serif;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 4px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
  --bg-primary: #E0E0E0;
  --bg-secondary: #E0E0E0;
  --bg-card: #FFFFFF;
  --text-primary: #03110D;
  --text-secondary: rgba(3, 17, 13, 0.6);
  --border-color: rgba(163, 133, 96, 0.4);
  --input-bg: rgba(224, 224, 224, 0.5);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1,
h2,
h3,
h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.title {
  font-size: 2.5rem;
  color: var(--accent-gold);
  margin-bottom: 1rem;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 300;
}

/* Navigation */
nav {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--accent-gold);
  font-weight: 600;
  letter-spacing: 1px;
}

.logo-img {
  height: 32px;
  width: auto;
  border-radius: var(--radius-sm);
}

.nav-links {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.nav-item {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0.5rem;
}

.nav-item:hover,
.nav-item.active {
  color: var(--accent-gold);
}

/* Main Container */
main {
  flex: 1;
  padding: 3rem 5%;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Sections */
.view-section {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.view-section.active {
  display: block;
}

#home.active {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: calc(100vh - 12rem);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    filter: blur(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

/* Morph transitions for browsers that support View Transitions API */
::view-transition-old(root) {
  animation: morph-out 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

::view-transition-new(root) {
  animation: morph-in 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes morph-out {
  from {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }

  to {
    opacity: 0;
    transform: scale(0.95);
    filter: blur(4px);
  }
}

@keyframes morph-in {
  from {
    opacity: 0;
    transform: scale(1.05);
    filter: blur(4px);
  }

  to {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

/* Buttons */
.btn-primary {
  background-color: var(--accent-gold);
  color: #03110D;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.85rem;
}

.btn-primary:hover {
  background-color: var(--accent-gold-hover);
  color: #E0E0E0;
  transform: translateY(-1px);
}

.btn-outline {
  background-color: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-sans);
}

.btn-outline:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* Forms & Inputs */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input,
select {
  background-color: var(--input-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  transition: var(--transition);
  outline: none;
  text-transform: uppercase;
}

input:focus,
select:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 1px var(--accent-gold);
}

/* Tables */
.table-container {
  overflow-x: auto;
  margin-top: 2rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background-color: var(--bg-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th,
td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

th {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: var(--bg-secondary);
}

/* Print Area specifically for browser preview */
.cheque-preview {
  width: 202mm;
  height: 92mm;
  background-color: #fefbeb;
  border-radius: 0;
  margin: 2rem auto;
  position: relative;
  overflow: visible;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  transform-origin: top center;
}

/* Dynamic overlay elements for preview */
.print-element {
  position: absolute;
  color: #000;
  font-family: 'Courier New', Courier, monospace;
  font-weight: bold;
  font-size: 14px;
  line-height: 1;
}

.ac-payee {
  top: 10%;
  left: 5%;
  font-size: 16px;
  text-decoration: underline;
  text-decoration-style: double;
}

.date-box {
  top: 10%;
  right: 5%;
  letter-spacing: 8px;
}

.payee-name {
  top: 30%;
  left: 10%;
}

.amount-words {
  top: 45%;
  left: 15%;
  width: 60%;
  line-height: 1.5;
}

.amount-figure {
  top: 50%;
  right: 5%;
  border: 1px solid #000;
  padding: 5px 15px;
}

/* Dashboard Widgets */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.stat-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
}

.stat-value {
  font-size: 2.5rem;
  font-family: var(--font-serif);
  color: var(--accent-gold);
  margin-bottom: 0.5rem;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Home Footer */
.home-footer {
  margin-top: auto;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.home-footer p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

.connect-links {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.connect-links a.icon-link {
  text-decoration: none;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.connect-links a.icon-link:hover {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
}

/* Custom Theme Toggle */
.theme-slider {
  display: inline-block;
  position: relative;
  width: 64px;
  height: 32px;
  cursor: pointer;
  margin-left: 10px;
}

.theme-slider input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #e2e8f0;
  border-radius: 32px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: .4s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
  border: 1px solid #cbd5e1;
}

.slider-thumb {
  position: absolute;
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: .4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

.theme-slider input:checked+.slider-track {
  background-color: #0f172a;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  border: 1px solid #1e293b;
}

.theme-slider input:checked+.slider-track .slider-thumb {
  transform: translateX(32px);
  background-color: #334155;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.icon-sun,
.icon-moon {
  width: 14px;
  height: 14px;
  z-index: 2;
  transition: .4s;
}

/* Light mode icon colors */
.icon-sun {
  color: #f97316;
  /* orange */
}

.icon-moon {
  color: #475569;
  /* slate gray */
}

/* Dark mode icon colors */
.theme-slider input:checked+.slider-track .icon-sun {
  color: #94a3b8;
  /* light gray */
}

.theme-slider input:checked+.slider-track .icon-moon {
  color: #fde047;
  /* yellow */
}

/* Calendar icon invert for dark mode */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0);
}

/* ----------------------------------------------------
   RESPONSIVE DESIGN (Screen)
   ---------------------------------------------------- */
@media screen and (max-width: 900px) {
  .cheque-preview {
    transform: scale(0.85);
    margin-bottom: -10mm;
  }
}

@media screen and (max-width: 768px) {
  nav {
    flex-wrap: wrap;
    padding: 1rem;
    gap: 1rem;
    justify-content: center;
  }
  
  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
  }
  
  main {
    padding: 1.5rem 1rem;
  }
  
  .card {
    padding: 1.25rem;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .cheque-preview {
    transform: scale(0.65);
    margin-bottom: -30mm;
  }
  
  .btn-primary, .btn-outline {
    min-height: 44px;
    width: 100%;
  }
  
  .title {
    font-size: 2rem;
  }
}

@media screen and (max-width: 480px) {
  .logo {
    justify-content: center;
    width: 100%;
  }

  .cheque-preview {
    transform: scale(0.40);
    margin-bottom: -50mm;
  }
  
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

/* ----------------------------------------------------
   PRINT MEDIA QUERY
   This handles actual physical printing, hiding UI
   ---------------------------------------------------- */
@media print {

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    background-color: white !important;
    color: black !important;
  }

  /* ------------------------------- */
  /* 1. CHEQUE PRINT MODE (DEFAULT)  */
  /* ------------------------------- */
  body:not(.print-report-mode) nav,
  body:not(.print-report-mode) #home,
  body:not(.print-report-mode) #issue,
  body:not(.print-report-mode) #report {
    display: none !important;
  }

  body:not(.print-report-mode) * {
    visibility: hidden;
  }

  body:not(.print-report-mode) #printableArea,
  body:not(.print-report-mode) #printableArea * {
    visibility: visible;
  }

  body:not(.print-report-mode) #printableArea {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 202mm !important;
    height: 92mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: black !important;
    overflow: hidden !important;
    page-break-after: avoid;
    page-break-inside: avoid;
    transform: none !important;
  }

  body:not(.print-report-mode) .print-element {
    color: black !important;
  }

  /* ------------------------------- */
  /* 2. REPORT PRINT MODE            */
  /* ------------------------------- */
  body.print-report-mode nav,
  body.print-report-mode #home,
  body.print-report-mode #issue,
  body.print-report-mode #print {
    display: none !important;
  }

  body.print-report-mode #report {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 2rem !important;
  }

  body.print-report-mode .card,
  body.print-report-mode .table-container {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    background-color: white !important;
  }

  body.print-report-mode select,
  body.print-report-mode button,
  body.print-report-mode .theme-slider {
    display: none !important;
  }

  body.print-report-mode table {
    width: 100% !important;
    border-collapse: collapse;
  }

  body.print-report-mode th,
  body.print-report-mode td {
    border: 1px solid #ccc;
    padding: 10px;
    color: black !important;
    background-color: transparent !important;
  }

  body.print-report-mode .stat-card {
    border: 1px solid #ccc;
    box-shadow: none !important;
    background-color: white !important;
  }

  body.print-report-mode .stat-value,
  body.print-report-mode h2,
  body.print-report-mode .stat-label {
    color: black !important;
  }
}