/* ============================================
   agiliza-finance - Modern Dark Mode Styles
   ============================================ */

/* Reset & Variables */
:root {
  /* Modern Purple/Blue Palette */
  --primary: #6d5dfc;
  --primary-hover: #5a4bd1;
  --primary-light: rgba(109, 93, 252, 0.15);
  --primary-glow: rgba(109, 93, 252, 0.4);

  --success: #00d68f;
  --success-hover: #00b377;
  --success-light: rgba(0, 214, 143, 0.15);

  --danger: #ff6b6b;
  --danger-hover: #ee5a5a;
  --danger-light: rgba(255, 107, 107, 0.15);

  --warning: #ffd93d;
  --info: #4ecdc4;

  /* Light Theme */
  --bg-primary: #f0f2f5;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #f8f9fa;
  --bg-hover: #f0f2f5;

  --text-primary: #1a1a2e;
  --text-secondary: #6c6c80;
  --text-tertiary: #9e9eb8;

  --border: #e8e8ef;
  --border-focus: #6d5dfc;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 4px 20px var(--primary-glow);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --radius-full: 9999px;

  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #1e1e35;
  --bg-input: #252542;
  --bg-hover: #2a2a45;

  --text-primary: #ffffff;
  --text-secondary: #a0a0b8;
  --text-tertiary: #6c6c80;

  --border: #2d2d4a;
  --border-focus: #6d5dfc;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 4px 30px var(--primary-glow);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  transition: background-color 0.3s, color 0.3s;
}

/* App Container */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 100px;
}

/* Header */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  font-size: 1.5rem;
}

.logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.logo-accent {
  color: var(--primary);
}

.header-right {
  display: flex;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

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

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

.btn-sm {
  padding: 8px 14px;
  font-size: 0.8rem;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: var(--transition);
  border: 1px solid var(--border);
}

.btn-icon:hover {
  background: var(--bg-hover);
  transform: scale(1.05);
}

/* Main Content */
.main {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}

/* Balance Card */
.balance-card {
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 50%, #a855f7 100%);
  border-radius: var(--radius);
  padding: 24px;
  color: white;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.balance-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 200px;
  height: 200px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

.balance-card::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -20%;
  width: 150px;
  height: 150px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}

.balance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.balance-label {
  font-size: 0.85rem;
  opacity: 0.9;
}

.balance-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.balance-value {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
  letter-spacing: -1px;
}

.balance-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.balance-item {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.balance-item-icon {
  font-size: 1.2rem;
}

.balance-item-info {
  display: flex;
  flex-direction: column;
}

.balance-item-label {
  font-size: 0.7rem;
  opacity: 0.9;
}

.balance-item-value {
  font-size: 1rem;
  font-weight: 700;
}

/* Quick Actions */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.quick-action-btn.income {
  background: var(--success-light);
  color: var(--success);
  border: 2px solid transparent;
}

.quick-action-btn.income:hover {
  border-color: var(--success);
  transform: translateY(-2px);
}

.quick-action-btn.expense {
  background: var(--danger-light);
  color: var(--danger);
  border: 2px solid transparent;
}

.quick-action-btn.expense:hover {
  border-color: var(--danger);
  transform: translateY(-2px);
}

.quick-action-icon {
  font-size: 1.3rem;
  font-weight: 700;
}

/* Charts Section */
.charts-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.chart-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.chart-header {
  margin-bottom: 16px;
}

.chart-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-wrapper {
  position: relative;
  height: 220px;
}

/* Transactions Section */
.transactions-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.transactions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.transaction-item {
  display: flex;
  align-items: center;
  padding: 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  gap: 12px;
}

.transaction-item:hover {
  background: var(--bg-hover);
}

.transaction-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.transaction-info {
  flex: 1;
  min-width: 0;
}

.transaction-description {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transaction-date {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.transaction-amount {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

.transaction-amount.income {
  color: var(--success);
}

.transaction-amount.expense {
  color: var(--danger);
}

.transaction-actions {
  flex-shrink: 0;
}

.btn-delete {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  opacity: 0.5;
  transition: var(--transition);
}

.btn-delete:hover {
  opacity: 1;
  background: var(--danger-light);
}

/* FAB Button */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: white;
  border: none;
  font-size: 1.8rem;
  font-weight: 300;
  cursor: pointer;
  box-shadow: var(--shadow-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  transition: var(--transition);
}

.fab:hover {
  transform: scale(1.1);
  background: var(--primary-hover);
}

.fab:active {
  transform: scale(0.95);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: flex-end;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-full {
  min-height: 80vh;
  border-radius: var(--radius) var(--radius) 0 0;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

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

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.btn-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: var(--transition);
}

.btn-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  transition: var(--transition);
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.input-with-icon {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-weight: 600;
  font-size: 1rem;
  z-index: 1;
  pointer-events: none;
}

.input-with-icon input {
  padding-left: 44px !important;
  font-size: 1rem;
  height: 48px;
}

/* Remove number input spinners */
.input-with-icon input::-webkit-outer-spin-button,
.input-with-icon input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-with-icon input[type=number] {
  -moz-appearance: textfield;
}

/* Type Toggle */
.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
}

.type-btn {
  padding: 12px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.type-btn.active[data-type="EXPENSE"] {
  background: var(--danger);
  color: white;
}

.type-btn.active[data-type="INCOME"] {
  background: var(--success);
  color: white;
}

.type-btn.active[data-type="BOTH"] {
  background: var(--primary);
  color: white;
}

.type-icon {
  font-size: 1rem;
}

/* Category Grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.category-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  cursor: pointer;
  transition: var(--transition);
}

.category-option:hover {
  border-color: var(--primary);
}

.category-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.category-option-icon {
  font-size: 1.3rem;
}

.category-option-name {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.2;
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.form-actions .btn {
  flex: 1;
}

/* Categories Modal */
.categories-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.categories-tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

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

.categories-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.category-item {
  display: flex;
  align-items: center;
  padding: 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  gap: 12px;
  border: 1px solid var(--border);
}

.category-item-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.category-item-info {
  flex: 1;
}

.category-item-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.category-item-type {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

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

/* Category Form */
.category-form {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-top: 16px;
  border: 1px solid var(--border);
}

.category-form h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Color Picker */
.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 3px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}

.color-btn:hover {
  transform: scale(1.1);
}

.color-btn.selected {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-card);
}

/* Icon Picker */
.icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-input);
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition);
}

.icon-btn:hover {
  border-color: var(--primary);
}

.icon-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 14px 24px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: var(--transition);
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.toast.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  background: var(--success);
  color: white;
}

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

.toast-icon {
  font-size: 1.1rem;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state-text {
  font-size: 0.9rem;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Desktop Adjustments */
@media (min-width: 768px) {
  .modal {
    align-items: center;
  }

  .modal-content {
    border-radius: var(--radius);
    margin: 0 16px;
  }

  .fab {
    bottom: 32px;
    right: 32px;
  }
}

/* Safe Area for Notch */
@supports (padding: env(safe-area-inset-top)) {
  .header {
    padding-top: calc(12px + env(safe-area-inset-top));
  }

  .fab {
    bottom: calc(24px + env(safe-area-inset-bottom));
    right: calc(24px + env(safe-area-inset-right));
  }
}
