/* ============================================
   ACCOUNTING SOFTWARE - DESIGN SYSTEM
   Modern, Responsive, Premium Design
   ============================================ */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ============================================
   CSS CUSTOM PROPERTIES
   ============================================ */
:root {
  /* Colors - Premium Palette */
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --success-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --warning-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);

  --primary: #667eea;
  --primary-dark: #5568d3;
  --primary-light: #8b9df8;

  --secondary: #764ba2;
  --accent: #f5576c;
  --success: #00f2fe;
  --warning: #fee140;
  --danger: #f5576c;

  /* Dark Mode Colors */
  --bg-primary: #0f0f1e;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #16213e;
  --bg-card: rgba(26, 26, 46, 0.6);
  --bg-glass: rgba(255, 255, 255, 0.05);

  --text-primary: #ffffff;
  --text-secondary: #b8b8d4;
  --text-muted: #6b6b8c;

  --border-color: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.2);

  /* Spacing Scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
  --font-size-4xl: 2.5rem;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.4);

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-base: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;

  /* Z-index Scale */
  --z-dropdown: 1000;
  --z-modal: 2000;
  --z-toast: 3000;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  background-image:
    radial-gradient(at 0% 0%, rgba(102, 126, 234, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(118, 75, 162, 0.15) 0px, transparent 50%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Hide number input spinners */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  -moz-appearance: textfield;
  /* Firefox */
  appearance: textfield;
  /* Standard */
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

h1 {
  font-size: var(--font-size-4xl);
}

h2 {
  font-size: var(--font-size-3xl);
}

h3 {
  font-size: var(--font-size-2xl);
}

h4 {
  font-size: var(--font-size-xl);
}

h5 {
  font-size: var(--font-size-lg);
}

h6 {
  font-size: var(--font-size-base);
}

p {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
}

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

a:hover {
  color: var(--primary);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

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

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.gap-lg {
  gap: var(--space-lg);
}

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

.text-muted {
  color: var(--text-muted);
}

.text-gradient {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.mb-sm {
  margin-bottom: var(--space-sm);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

.mb-xl {
  margin-bottom: var(--space-xl);
}

.mt-sm {
  margin-top: var(--space-sm);
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.hidden {
  display: none;
}

/* ============================================
   GRID SYSTEM
   ============================================ */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
}

/* ============================================
   GLASSMORPHISM CARD
   ============================================ */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-base);
}

.glass-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-base);
}

.card:hover {
  border-color: var(--border-hover);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.75rem 1.5rem;
  font-size: var(--font-size-base);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  border-color: var(--primary);
  background: var(--bg-tertiary);
}

.btn-success {
  background: var(--success-gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(0, 242, 254, 0.3);
}

.btn-danger {
  background: var(--secondary-gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: var(--font-size-sm);
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: var(--font-size-lg);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
  margin-bottom: var(--space-lg);
  position: relative;
}

.form-label {
  display: block;
  margin-bottom: var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  background: var(--bg-tertiary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* Floating Label Effect */
.form-floating {
  position: relative;
}

.form-floating .form-input {
  padding-top: 1.5rem;
  padding-bottom: 0.5rem;
}

.form-floating .form-label {
  position: absolute;
  top: 1rem;
  left: 1rem;
  margin: 0;
  pointer-events: none;
  transition: all var(--transition-fast);
}

.form-floating .form-input:focus~.form-label,
.form-floating .form-input:not(:placeholder-shown)~.form-label {
  top: 0.25rem;
  font-size: var(--font-size-xs);
  color: var(--primary);
}

/* ============================================
   TABLES
   ============================================ */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead {
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
}

.table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--bg-secondary);
}

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

/* ============================================
   BADGES & STATUS
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: var(--font-size-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-success {
  background: rgba(0, 242, 254, 0.2);
  color: var(--success);
  border: 1px solid rgba(0, 242, 254, 0.3);
}

.badge-warning {
  background: rgba(254, 225, 64, 0.2);
  color: var(--warning);
  border: 1px solid rgba(254, 225, 64, 0.3);
}

.badge-danger {
  background: rgba(245, 87, 108, 0.2);
  color: var(--danger);
  border: 1px solid rgba(245, 87, 108, 0.3);
}

.badge-primary {
  background: rgba(102, 126, 234, 0.2);
  color: var(--primary-light);
  border: 1px solid rgba(102, 126, 234, 0.3);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

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

@keyframes slideIn {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(0);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.fade-in {
  animation: fadeIn 0.5s ease-out;
}

.slide-in {
  animation: slideIn 0.3s ease-out;
}

/* ============================================
   MODALS
   ============================================ */
.modal-xl {
  width: 95%;
  max-width: 900px !important;
}

.modal-xl .table th:nth-child(1),
.modal-xl .table td:nth-child(1) {
  width: auto;
}

.modal-xl .table th:nth-child(2),
.modal-xl .table td:nth-child(2) {
  width: auto;
}

.modal-xl .table th:nth-child(3),
.modal-xl .table td:nth-child(3) {
  width: auto;
}

/* Rate (3) and Tax (4) removed, Actions or Total will take remaining */

/* ============================================
   FILTER BAR & ACTIONS
   ============================================ */
.filter-bar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.datepicker-container {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--bg-glass);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.datepicker-container .form-input {
  width: 170px;
  background: transparent;
  border: none;
  padding: 0.5rem;
}

.datepicker-container .form-input:focus {
  background: rgba(255, 255, 255, 0.05);
  box-shadow: none;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  :root {
    --font-size-4xl: 2rem;
    --font-size-3xl: 1.5rem;
    --font-size-2xl: 1.25rem;
  }

  .container {
    padding: 0 var(--space-md);
  }

  .glass-card {
    padding: var(--space-lg);
  }

  /* Stackable Table (Card View on Mobile) */
  .table,
  .table thead,
  .table tbody,
  .table th,
  .table td,
  .table tr {
    display: block;
  }

  .table thead {
    display: none;
    /* Hide headers */
  }

  .table tr {
    margin-bottom: var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    padding: var(--space-sm);
    box-shadow: var(--shadow-sm);
  }

  .table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    text-align: right;
  }

  .table td:last-child {
    border-bottom: none;
    justify-content: center;
    padding-top: var(--space-md);
  }

  .table td::before {
    content: attr(data-label);
    font-weight: 700;
    text-transform: uppercase;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-right: var(--space-md);
    flex-shrink: 0;
    text-align: left;
  }

  .table td:last-child::before {
    display: none;
    /* Hide label for actions column */
  }

  .table-container {
    background: transparent;
    border: none;
    overflow-x: visible;
    /* Remove horizontal scroll */
  }

  /* Filter Bar Mobile Enhancements */
  .filter-bar-actions {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
  }

  .datepicker-container {
    flex-direction: row;
    /* Keep start/end date on same row if possible? No, probably too tight. */
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
    padding: var(--space-xs);
    gap: var(--space-xs);
  }

  .datepicker-container .form-input {
    flex: 1;
    min-width: 100px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
  }

  .datepicker-container .text-muted {
    display: none;
    /* Hide 'to' on mobile if stacked */
  }

  .filter-bar-actions .flex {
    flex-wrap: wrap;
    gap: var(--space-xs) !important;
  }

  .filter-bar-actions .search-bar {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Compact button on mobile if it's just an icon */
  .filter-bar-actions .btn-sm {
    width: auto !important;
    flex-shrink: 0;
  }

  .form-group {
    margin-bottom: var(--space-md);
  }
}

@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  .btn {
    padding: 0.625rem 1.25rem;
    width: 100%;
    /* Full width buttons on very small screens */
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    flex-direction: column;
  }

  .topbar-actions .btn {
    width: 100%;
  }
}
/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .sidebar,
  .topbar,
  .btn,
  .modal-overlay,
  .filter-bar-actions,
  .no-print {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  body {
    background: white !important;
    color: black !important;
  }
  
  .glass-card {
    box-shadow: none !important;
    border: none !important;
    background: white !important;
    backdrop-filter: none !important;
    padding: 0 !important;
  }

  /* Ensure table fits */
  .table {
    width: 100% !important;
    border: 1px solid #ddd !important;
  }
  
  .table th, .table td {
      color: black !important;
      border-color: #ddd !important;
  }
}
