/* CSS Custom Properties */
:root {
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --primary-color: #667eea;
  --primary-dark: #764ba2;
  --secondary-color: #6c757d;
  --success-color: #28a745;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --info-color: #17a2b8;

  --text-primary: #1a1a1a;
  --text-secondary: #6c757d;
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --border-color: #e0e0e0;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);

  --sidebar-width: 260px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  :root {
    --text-primary: #f5f5f5;
    --text-secondary: #b0b0b0;
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --border-color: #404040;
  }
}

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

html,
body {
  width: 100%;
  height: 100%;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
}

/* LOGIN PAGE */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--primary-gradient);
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: var(--bg-primary);
  border-radius: 12px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 40px;
}

.login-header h1 {
  font-size: 2.5em;
  color: var(--primary-color);
  margin-bottom: 8px;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 1em;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form .form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9em;
}

.login-form .form-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 1em;
  transition: var(--transition);
}

.login-form .form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.error-message {
  color: var(--danger-color);
  background-color: rgba(220, 53, 69, 0.1);
  padding: 12px;
  border-radius: 6px;
  margin-top: 15px;
  font-weight: 600;
  text-align: center;
}

/* MAIN APP */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  z-index: 100;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
  font-size: 1.5em;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

.nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.95em;
  font-weight: 500;
}

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

.nav-btn.active {
  background: linear-gradient(90deg, rgba(102, 126, 234, 0.1), transparent);
  color: var(--primary-color);
  border-left: 4px solid var(--primary-color);
  padding-left: 20px;
}

.nav-btn .icon {
  font-size: 1.3em;
  width: 24px;
  text-align: center;
}

.nav-btn .label {
  flex: 1;
  text-align: left;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
}

.user-info {
  margin-bottom: 16px;
}

.user-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9em;
  margin-bottom: 2px;
}

.user-role {
  font-size: 0.8em;
  color: var(--text-secondary);
}

/* MAIN CONTENT */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-header {
  background: var(--primary-gradient);
  color: white;
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.top-header h1 {
  font-size: 1.8em;
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-user {
  font-size: 0.95em;
  margin: 0;
}

/* PAGE CONTENT */
.page-content {
  display: none;
  overflow-y: auto;
  flex: 1;
  padding: 30px;
}

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

/* OVERVIEW TABS */
.overview-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 30px;
}

.overview-tab {
  padding: 10px 20px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition);
}

.overview-tab:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.overview-tab.active {
  background: var(--primary-gradient);
  color: white;
  border-color: var(--primary-color);
}

/* STATISTICS GRID */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--bg-primary);
  padding: 24px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary-color);
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.stat-card h3 {
  font-size: 0.85em;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 2.8em;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card-primary {
  border-left-color: #667eea;
}

.stat-card-success {
  border-left-color: var(--success-color);
}

.stat-card-success .stat-value {
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card-warning {
  border-left-color: var(--warning-color);
}

.stat-card-warning .stat-value {
  background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card-info {
  border-left-color: var(--info-color);
}

.stat-card-info .stat-value {
  background: linear-gradient(135deg, #17a2b8 0%, #00bcd4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* CHART SECTION */
.chart-section {
  background: var(--bg-primary);
  padding: 30px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
}

.chart-section h2 {
  font-size: 1.5em;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.chart-container {
  position: relative;
  height: 300px;
}

/* DASHBOARD GRID */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.filter-section,
.calendar-section {
  background: var(--bg-primary);
  padding: 15px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  height: fit-content;
}

.filter-section h2,
.calendar-section h2 {
  font-size: 1.1em;
  margin-bottom: 12px;
  color: var(--text-primary);
}

/* PAGE GRID */
.page-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
  margin-bottom: 30px;
}

/* FORM SECTION */
.form-section {
  background: var(--bg-primary);
  padding: 30px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.form-section h2 {
  font-size: 1.5em;
  margin-bottom: 24px;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 12px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-family: inherit;
  font-size: 1em;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: var(--transition);
}

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

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

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

/* BUTTONS */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
  background: var(--secondary-color);
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
  transform: translateY(-2px);
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  background: #c82333;
  transform: translateY(-2px);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.9em;
}

.btn-large {
  width: 100%;
  padding: 14px;
  font-size: 1.05em;
}

/* TABLES */
.table-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.table-wrapper {
  background: var(--bg-primary);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  overflow-x: auto;
}

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

thead {
  background: var(--primary-gradient);
  color: white;
}

th {
  padding: 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.95em;
}

td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

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

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

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* MODALS */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  overflow: auto;
  animation: fadeIn 0.3s;
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  background-color: var(--bg-primary);
  border-radius: 12px;
  width: 95%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s;
}

@keyframes slideUp {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.3em;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-content form {
  padding: 24px;
}

.modal-content .form-group {
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.modal-actions button {
  min-width: 120px;
}

.stats-details {
  padding: 24px;
}

.stats-details p {
  margin-bottom: 16px;
  font-size: 1em;
  display: flex;
  justify-content: space-between;
}

/* CALENDAR */
.calendar {
  background: transparent;
  padding: 0;
  border-radius: 0;
  overflow-x: hidden;
}

.calendar-day {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 1px;
  padding: 0;
  border-radius: 4px;
  background: #f5f5f5;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.75em;
  font-weight: 600;
}

.calendar-day:hover {
  background: var(--primary-gradient);
  color: white;
}

.calendar-day.has-data {
  background: var(--primary-gradient);
  color: white;
}

/* BADGES */
.badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85em;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success {
  background-color: rgba(40, 167, 69, 0.1);
  color: var(--success-color);
}

.badge-danger {
  background-color: rgba(220, 53, 69, 0.1);
  color: var(--danger-color);
}

.badge-warning {
  background-color: rgba(255, 193, 7, 0.1);
  color: var(--warning-color);
}

/* RESPONSIVE */
@media (max-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 900px) {
  .sidebar {
    width: 200px;
    --sidebar-width: 200px;
  }

  .sidebar-header {
    padding: 16px;
  }

  .nav-btn {
    padding: 12px 16px;
  }

  .nav-btn .icon {
    font-size: 1.2em;
  }

  .nav-btn .label {
    display: none;
  }

  .nav-btn.active {
    padding-left: 16px;
    border-left: 4px solid var(--primary-color);
  }

  .top-header {
    padding: 16px;
  }

  .top-header h1 {
    font-size: 1.3em;
  }

  .page-content {
    padding: 20px;
  }

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

  .chart-container {
    height: 250px;
  }

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

@media (max-width: 600px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .sidebar-header {
    padding: 12px;
    border-right: 1px solid var(--border-color);
    border-bottom: none;
  }

  .sidebar-header h2 {
    font-size: 1.2em;
  }

  .sidebar-nav {
    flex-direction: row;
    padding: 0;
    overflow-y: visible;
    overflow-x: auto;
  }

  .nav-btn {
    padding: 12px;
    white-space: nowrap;
    border-left: none;
    border-bottom: 3px solid transparent;
  }

  .nav-btn.active {
    border-left: none;
    border-bottom: 3px solid var(--primary-color);
    padding-left: 12px;
  }

  .sidebar-footer {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  .top-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .page-content {
    padding: 16px;
  }

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

  .chart-container {
    height: 200px;
  }

  .form-section {
    padding: 16px;
  }

  .table-wrapper {
    font-size: 0.9em;
  }

  th,
  td {
    padding: 12px 8px;
  }

  .actions {
    flex-direction: column;
  }

  .modal-content {
    width: 90%;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-content form {
    padding: 16px;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions button {
    width: 100%;
  }
}

/* ============================================
   INVOICE NUMBER COLUMN STYLING
   ============================================ */

.invoice-number-cell {
  cursor: pointer;
  position: relative;
  padding: 0.5rem;
}

.invoice-number-cell:hover {
  background-color: rgba(102, 126, 234, 0.05);
  border-radius: 4px;
}

.invoice-placeholder {
  color: #999;
  font-style: italic;
  font-size: 0.9rem;
}

.invoice-value {
  font-weight: 500;
  color: #333;
}

/* Edit Mode Styling */
.invoice-number-cell.editing {
  background-color: #e7f3ff;
  border: 2px solid #0078d4;
  border-radius: 4px;
  padding: 0.25rem;
}

.invoice-input {
  width: 100%;
  padding: 0.35rem;
  border: none;
  background-color: transparent;
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
}

.invoice-input:focus {
  outline: none;
}

/* Checkmark Animation */
.invoice-checkmark {
  display: inline-block;
  margin-left: 0.5rem;
  color: #28a745;
  font-weight: bold;
  font-size: 1.2rem;
  animation: fadeOutCheckmark 1.5s ease-out forwards;
}

@keyframes fadeOutCheckmark {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* Error State */
.invoice-number-cell.invoice-error {
  background-color: #ffe7e7;
  border-radius: 4px;
}

/* Filter Group Styling */
.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-group label {
  font-weight: 500;
  margin: 0;
  white-space: nowrap;
}

.filter-group select {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: white;
  font-size: 1rem;
  cursor: pointer;
}

.filter-group select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .invoice-value {
    color: #e0e0e0;
  }

  .invoice-placeholder {
    color: #666;
  }

  .invoice-number-cell:hover {
    background-color: rgba(102, 126, 234, 0.15);
  }

  .invoice-number-cell.editing {
    background-color: #1e3a5f;
    border-color: #0078d4;
  }

  .invoice-input {
    color: #e0e0e0;
  }

  .invoice-number-cell.invoice-error {
    background-color: #5f1e1e;
  }

  .filter-group select {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border-color: #444;
  }

  .filter-group select:focus {
    border-color: #667eea;
  }
}
