:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --secondary: #3b82f6;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg-main: #f8fafc;
  --bg-sidebar: #1e293b;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --white: #ffffff;
  --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Login Screen Styles */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  padding: 1.5rem;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
}

.login-card {
  background: white;
  padding: 2.5rem;
  border-radius: 1.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

.login-header h1 {
  font-size: 1.75rem;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
}

.logged-user-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.user-role-text {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
  color: #94a3b8;
}

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

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  overflow-x: hidden;
}

#app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: 2rem 0;
  position: fixed;
  height: 100vh;
  z-index: 1000;
  transition: var(--transition);
}

.sidebar.hidden {
  transform: translateX(-100%);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 3rem;
  padding: 0 1.5rem;
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.nav-links {
  list-style: none;
  flex-grow: 1;
}

.nav-links li {
  margin-bottom: 0.5rem;
}

.nav-links a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-weight: 500;
  transition: var(--transition);
}

.nav-links li.active a,
.nav-links a:hover {
  color: var(--white);
  background-color: rgba(255, 255, 255, 0.1);
}

.nav-links li.active a {
  border-left: 4px solid var(--primary);
}

/* Main Content Styling */
.main-content {
  flex-grow: 1;
  margin-left: 260px;
  padding: 2rem;
  width: calc(100% - 260px);
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.search-container input {
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid #e2e8f0;
  width: 300px;
  outline: none;
}

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

.user-name {
  font-weight: 600;
}

.badge {
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.admin {
  background-color: #fee2e2;
  color: #991b1b;
}

.badge.editor {
  background-color: #fef3c7;
  color: #92400e;
}

.badge.viewer {
  background-color: #e0f2fe;
  color: #075985;
}

/* Grid Layouts */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.main-section {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

/* Card Styling */
.card {
  background-color: var(--white);
  padding: 1.5rem;
  border-radius: 1rem;
  box-shadow: var(--card-shadow);
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
}

.stat-icon.income {
  background-color: #dcfce7;
  color: #166534;
}

.stat-icon.deposits {
  background-color: #e0f2fe;
  color: #075985;
}

.stat-icon.expenses {
  background-color: #fee2e2;
  color: #991b1b;
}

.stat-icon.balance {
  background-color: #f3e8ff;
  color: #6b21a8;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
}

/* Table Styling */
.table-container {
  background-color: var(--white);
  border-radius: 1rem;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

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

th {
  background-color: #f8fafc;
  padding: 1rem 1.5rem;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 2px solid #f1f5f9;
}

td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
}

tfoot td {
  background: #f8fafc;
  border-top: 2px solid #e2e8f0;
  padding: 1.25rem 1.5rem;
}

.monto {
  font-family: 'Courier New', Courier, monospace;
  font-weight: 600;
}

.text-positive {
  color: #10b981;
}

.text-negative {
  color: #ef4444;
}

/* Filter Bar Styling */
.filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 0.75rem;
  border: 1px solid #e2e8f0;
}

.filter-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-group label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.range-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.range-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.query-input,
.date-input,
.category-input {
  padding: 0.6rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  outline: none;
  font-size: 0.875rem;
  background: white;
  transition: var(--transition);
}

.query-input {
  min-width: 200px;
}

.date-input {
  min-width: 140px;
}

.category-input {
  min-width: 160px;
}

.query-input:focus,
.date-input:focus,
.category-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Button Styling */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  outline: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

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

.btn-primary:hover {
  background-color: var(--primary-dark);
}

.btn-secondary {
  background-color: #f1f5f9;
  color: #475569;
}

.btn-secondary:hover {
  background-color: #e2e8f0;
}

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

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-icon-alt {
  padding: 0.5rem;
  border-radius: 0.375rem;
  border: 1px solid #e2e8f0;
  background: white;
  cursor: pointer;
  transition: var(--transition);
}

.btn-icon-alt:hover {
  background: #f8fafc;
  border-color: var(--primary);
}

/* Export Actions */
.export-actions {
  display: flex;
  gap: 0.75rem;
}

.header-action {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.5rem;
}

/* Category Pills */
.category-pill {
  padding: 0.25rem 0.6rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.pill-rental {
  background-color: #dcfce7;
  color: #166534;
}

.pill-deposit {
  background-color: #e0f2fe;
  color: #075985;
}

.pill-expense {
  background-color: #fee2e2;
  color: #991b1b;
}

/* Status Check */
.status-v {
  color: #10b981;
  font-weight: bold;
}

/* Modal Styling */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal.show {
  display: flex;
}

.modal-content {
  background-color: var(--white);
  width: 100%;
  max-width: 500px;
  border-radius: 1rem;
  padding: 2rem;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Scan modal specific styles for desktop */
#scan-modal .modal-content {
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#scan-modal .scan-container {
  flex: 1;
  overflow-y: auto;
}

/* Ensure OCR results section is scrollable */
#scan-modal #ocr-results {
  display: flex;
  flex-direction: column;
  max-height: 50vh;
}

#scan-modal #extracted-transactions {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 1rem;
}

/* Keep action buttons visible at bottom */
#scan-modal #ocr-results > div:last-child {
  position: sticky;
  bottom: 0;
  background: white;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
  z-index: 10;
}

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

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

.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.6rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  outline: none;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1.5rem;
}

.hidden {
  display: none !important;
}

/* Receipts View Styles */
.receipt-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 2rem;
  align-items: start;
}

.drag-area {
  border: 2px dashed #e2e8f0;
  height: 200px;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 1.5rem;
  background: #f8fafc;
}

.drag-area:hover,
.drag-area.active {
  border-color: var(--primary);
  background: rgba(16, 185, 129, 0.05);
}

.drag-area .icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.drag-area header {
  font-size: 1rem;
  font-weight: 600;
}

.drag-area span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.upload-controls {
  padding: 0 0.5rem;
}

.receipts-list {
  padding: 1rem;
  max-height: 500px;
  overflow-y: auto;
}

.receipt-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid #f1f5f9;
  transition: var(--transition);
}

.receipt-item:hover {
  background: #f8fafc;
}

.receipt-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.receipt-info .date {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.receipt-info .desc {
  font-weight: 600;
  font-size: 0.9rem;
}

.receipt-actions {
  display: flex;
  gap: 0.5rem;
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Mobile Responsiveness */
@media (max-width: 1024px) {
  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 1rem;
  }

  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-only {
    display: block;
  }

  .top-bar {
    gap: 1rem;
  }

  .search-container input {
    width: 100%;
  }

  .btn-text {
    display: none !important;
  }

  .export-actions .btn-sm {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.25rem;
  }

  tfoot td[colspan="5"] {
    display: none;
  }

  tfoot td {
    text-align: center !important;
    width: 100%;
  }

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

  .filters {
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .range-group {
    width: 100%;
  }

  .query-input,
  .date-input,
  .category-input {
    width: 100%;
    min-width: unset;
  }

  .range-group label {
    min-width: 50px;
  }
}

/* Scan Receipt Styles */
.scan-container {
  padding: 1rem;
}

.camera-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 300px;
}

#scan-receipt-btn {
  white-space: nowrap;
}

.btn-success {
  background: #10b981;
  color: white;
}

.btn-success:hover {
  background: #059669;
}

/* Mobile specific styles */
@media (max-width: 1024px) {
  #scan-receipt-btn {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
  }
  
  .header-action > div:last-child {
    flex-wrap: wrap;
  }

  /* Scan modal mobile adjustments */
  #scan-modal .modal-content {
    max-height: 90vh;
    overflow-y: auto;
    margin: 1rem;
  }

  .scan-container {
    padding: 0.5rem;
  }

  #ocr-results {
    max-height: none !important;
    margin-bottom: 1rem;
  }

  #extracted-transactions {
    max-height: 40vh !important;
    overflow-y: auto;
    margin-bottom: 1rem;
  }

  /* Asegurar que los botones de acción sean visibles */
  #ocr-results > div:last-child {
    position: sticky;
    bottom: 0;
    background: white;
    padding: 1rem 0.5rem;
    border-top: 1px solid #e2e8f0;
    margin-top: 1rem;
    z-index: 10;
  }
}