/* enhanced-expenses.css - Enhanced Expenses Styling */

/* Category Management Modal */
.category-modal .uba-modal-dialog {
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
}

.category-modal .category-dialog {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.category-modal .category-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Category Form Section */
.category-form-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
}

.category-form-section h4 {
  margin: 0 0 16px 0;
  color: #1e293b;
  font-size: 16px;
  font-weight: 600;
}

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

.category-form-grid .form-group.full-width {
  grid-column: 1 / -1;
}

.category-form .form-group {
  margin-bottom: 0;
}

.category-form .form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: #374151;
  font-size: 14px;
}

/* Icon Selector */
.icon-selector {
  position: relative;
}

.icon-input {
  text-align: center;
  font-size: 18px;
  padding-right: 40px;
}

.icon-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.icon-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  font-size: 16px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-option:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  transform: scale(1.1);
}

/* Color Picker */
.color-picker {
  width: 100%;
  height: 40px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.color-picker:hover {
  border-color: #94a3b8;
}

/* Checkbox Styling */
.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: normal;
  margin-bottom: 0;
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid #d1d5db;
  border-radius: 4px;
  margin-right: 8px;
  position: relative;
  transition: all 0.2s ease;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
  background: #3b82f6;
  border-color: #3b82f6;
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

/* Form Actions */
.category-form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* Categories List Section */
.category-list-section h4 {
  margin: 0 0 16px 0;
  color: #1e293b;
  font-size: 16px;
  font-weight: 600;
}

.categories-grid {
  display: grid;
  gap: 16px;
}

/* Category Item */
.category-item {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  transition: all 0.2s ease;
}

.category-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.category-item.inactive {
  opacity: 0.6;
  background: #f8fafc;
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.category-icon-name {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.category-icon {
  font-size: 24px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  border-radius: 6px;
}

.category-names {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.category-name {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.category-name-ar {
  font-size: 13px;
  color: #64748b;
  font-style: italic;
  margin: 0;
}

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

.category-details {
  margin-top: 8px;
}

.category-description {
  font-size: 14px;
  color: #64748b;
  margin: 0 0 8px 0;
}

.category-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.category-budget {
  color: #059669;
  font-weight: 500;
}

.category-status {
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.category-status.active {
  background: #dcfce7;
  color: #166534;
}

.category-status.inactive {
  background: #f1f5f9;
  color: #475569;
}

/* Charts Section */
.charts-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 24px;
}

.chart-card {
  min-height: 400px;
}

.chart-card .uba-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.chart-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

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

.chart-content canvas {
  max-height: 300px;
}

/* Chart Legend */
.chart-legend {
  margin-top: 20px;
  max-height: 200px;
  overflow-y: auto;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
}

.legend-item:last-child {
  border-bottom: none;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.legend-label {
  flex: 1;
  font-weight: 500;
  color: #374151;
}

.legend-value {
  font-weight: 600;
  color: #1e293b;
}

/* Chart Summary */
.chart-summary {
  margin-top: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
}

.summary-item {
  text-align: center;
  padding: 12px;
  background: #f8fafc;
  border-radius: 6px;
}

.summary-label {
  display: block;
  font-size: 12px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.summary-value {
  display: block;
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
}

/* Fallback Charts */
.fallback-pie-chart {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
}

.pie-chart-fallback {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: conic-gradient(
    #3b82f6 0deg 120deg,
    #8b5cf6 120deg 180deg,
    #10b981 180deg 240deg,
    #f59e0b 240deg 300deg,
    #ef4444 300deg 360deg
  );
}

.pie-chart-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100px;
  height: 100px;
  background: white;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.pie-chart-center strong {
  font-size: 14px;
  color: #1e293b;
}

.pie-chart-center small {
  font-size: 11px;
  color: #64748b;
}

.fallback-trend-chart {
  padding: 20px;
}

.trend-chart-bars {
  display: flex;
  align-items: end;
  gap: 8px;
  height: 200px;
}

.trend-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
}

.bar {
  width: 100%;
  max-width: 40px;
  background: linear-gradient(to top, #3b82f6, #60a5fa);
  border-radius: 4px 4px 0 0;
  margin-bottom: 8px;
  transition: all 0.3s ease;
}

.bar:hover {
  background: linear-gradient(to top, #1d4ed8, #3b82f6);
}

.bar-label {
  font-size: 11px;
  color: #64748b;
  text-align: center;
  transform: rotate(-45deg);
  white-space: nowrap;
}

/* Receipt Upload Section */
.receipt-upload-section {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.upload-tabs {
  display: flex;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.upload-tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: #64748b;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.upload-tab:hover {
  background: #e2e8f0;
}

.upload-tab.active {
  background: white;
  color: #3b82f6;
  border-bottom: 2px solid #3b82f6;
}

.upload-content {
  position: relative;
}

.upload-tab-content {
  display: none;
  padding: 20px;
}

.upload-tab-content.active {
  display: block;
}

/* File Upload Area */
.file-upload-area {
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  padding: 40px 20px;
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
}

.file-upload-area:hover {
  border-color: #3b82f6;
  background: #f8fafc;
}

.file-upload-area.drag-over {
  border-color: #3b82f6;
  background: #eff6ff;
  transform: scale(1.02);
}

.file-input {
  display: none;
}

.upload-prompt {
  margin-bottom: 20px;
}

.upload-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 12px;
}

.upload-prompt p {
  margin: 0 0 8px 0;
  color: #374151;
  font-size: 16px;
}

.upload-link {
  background: none;
  border: none;
  color: #3b82f6;
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
}

.upload-link:hover {
  color: #1d4ed8;
}

.upload-prompt small {
  color: #64748b;
  font-size: 12px;
}

/* Uploaded Files */
.uploaded-files {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.uploaded-file {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-icon {
  font-size: 20px;
}

.file-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-name {
  font-size: 14px;
  color: #1e293b;
  margin: 0;
}

.file-size {
  font-size: 12px;
  color: #64748b;
}

.file-actions {
  display: flex;
  gap: 4px;
}

/* Enhanced Dropdowns */
.enhanced-dropdown {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #1e293b;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  transition: all 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 8px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 32px;
}

.enhanced-dropdown:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%233b82f6' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
}

.enhanced-dropdown:hover {
  border-color: #94a3b8;
}

.enhanced-dropdown option {
  font-weight: 500;
  padding: 8px 12px;
  color: #1e293b;
}

/* Image Preview Modal */
.image-preview-modal .image-preview-dialog {
  max-width: 90vw;
  max-height: 90vh;
}

.preview-image {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .category-form-grid {
    grid-template-columns: 1fr;
  }
  
  .charts-container {
    grid-template-columns: 1fr;
  }
  
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .category-modal .uba-modal-dialog {
    width: 95%;
    margin: 10px;
  }
  
  .chart-card .uba-card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .chart-controls {
    justify-content: stretch;
  }
  
  .upload-tabs {
    flex-direction: column;
  }
  
  .upload-tab {
    text-align: left;
  }
}

@media (max-width: 480px) {
  .file-upload-area {
    padding: 20px 12px;
  }
  
  .upload-icon {
    font-size: 24px;
  }
  
  .upload-prompt p {
    font-size: 14px;
  }
  
  .summary-grid {
    grid-template-columns: 1fr;
  }
}

/* Animation Enhancements */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.category-item {
  animation: slideInUp 0.3s ease;
}

.uploaded-file {
  animation: slideInUp 0.2s ease;
}

/* Loading States */
.chart-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: #64748b;
  font-size: 14px;
}

.chart-loading::before {
  content: '⏳';
  font-size: 24px;
  margin-right: 8px;
}

/* Enhanced Visual Polish */
.uba-btn-ghost {
  border: 1px solid #e2e8f0;
  transition: all 0.2s ease;
}

.uba-btn-ghost:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.chart-card {
  transition: all 0.3s ease;
}

.chart-card:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}