/* ═══════════════════════════════════════════════════════════════════
   COMPONENTS — Reusable UI Components
   All using CSS logical properties for RTL compatibility
   ═══════════════════════════════════════════════════════════════════ */

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  min-height: 44px;
  min-width: 44px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px var(--accent-glow); }

.btn--secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-2);
}
.btn--secondary:hover { background: var(--surface-3); border-color: var(--border-3); }

.btn--danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.2);
}
.btn--danger:hover { background: rgba(248,113,113,0.2); }

.btn--ghost {
  background: transparent;
  color: var(--text-2);
}
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }

.btn--sm { padding: 0.5rem 0.875rem; font-size: 0.8125rem; min-height: 36px; }
.btn--lg { padding: 1rem 1.75rem; font-size: 1rem; }
.btn--full { width: 100%; }
.btn--icon { padding: 0.625rem; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Form Inputs ─────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-block-end: 1rem;
}

.form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
  transition: border-color var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

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

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%238b92a5' stroke-width='2'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: inline-end 0.75rem center;
  padding-inline-end: 2.5rem;
}

[dir="rtl"] .form-select {
  background-position: left 0.75rem center;
}

.form-error {
  font-size: 0.75rem;
  color: var(--red);
  margin-block-start: 0.25rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-3);
}

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

@media (min-width: 768px) {
  .form-row--2 { grid-template-columns: 1fr 1fr; }
  .form-row--3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color var(--transition);
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: 1rem;
}

.card-title { font-size: 1rem; font-weight: 600; }
.card-subtitle { font-size: 0.8125rem; color: var(--text-2); }

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-2);
}

/* ── Tables ──────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  padding: 0.75rem 1rem;
  text-align: start;
  font-weight: 500;
  color: var(--text-2);
  border-block-end: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 0.75rem 1rem;
  border-block-end: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:hover td { background: var(--surface-2); }

.table--striped tr:nth-child(even) td { background: rgba(255,255,255,0.02); }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge--green  { background: var(--green-bg); color: var(--green); }
.badge--red    { background: var(--red-bg); color: var(--red); }
.badge--yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge--blue   { background: var(--blue-bg); color: var(--blue); }
.badge--gray   { background: rgba(255,255,255,0.06); color: var(--text-2); }

/* ── Toast ────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--mobile-nav-h) + 1rem);
  inset-inline-start: 50%;
  transform: translateX(-50%) translateY(120%);
  padding: 0.875rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  max-width: 90vw;
}

[dir="rtl"] .toast { transform: translateX(50%) translateY(120%); }

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

[dir="rtl"] .toast.show { transform: translateX(50%) translateY(0); }

.toast--success { background: var(--green); color: #0d0f14; }
.toast--error   { background: var(--red); color: #fff; }
.toast--warning { background: var(--yellow); color: #0d0f14; }

@media (min-width: 768px) {
  .toast { bottom: 2rem; }
}

/* ── Flash Messages ──────────────────────────────────────────────── */
.flash-container { margin-block-end: 1rem; }

.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-block-end: 0.5rem;
  animation: slideDown 0.3s ease;
}

.flash--success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,211,163,0.2); }
.flash--danger, .flash--error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(248,113,113,0.2); }
.flash--warning { background: var(--yellow-bg); color: var(--yellow); border: 1px solid rgba(251,191,36,0.2); }
.flash--info    { background: var(--blue-bg); color: var(--blue); border: 1px solid rgba(96,165,250,0.2); }

.flash-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  margin-inline-start: 0.5rem;
  opacity: 0.7;
}
.flash-close:hover { opacity: 1; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-0.5rem); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 500px;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal { transform: scale(1); }

.modal-title { font-size: 1.125rem; font-weight: 600; margin-block-end: 1rem; }

.modal-confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--red-bg);
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-block-end: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-block-start: 1.5rem;
}

.action-cell {
  display: flex;
  gap: 0.375rem;
  justify-content: flex-end;
  align-items: center;
}

.expense-card-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.toast-undo-btn {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  margin-inline-start: 0.75rem;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.toast-undo-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ── Loading Spinner & Skeletons ─────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-2);
  border-block-start-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner--lg { width: 32px; height: 32px; border-width: 3px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton Shimmer */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 25%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 1rem;
  margin-block-end: 0.5rem;
  border-radius: var(--radius-xs);
}

.skeleton-text--short { width: 40%; }
.skeleton-text--medium { width: 70%; }

.skeleton-card {
  height: 110px;
  border-radius: var(--radius);
}

.skeleton-row {
  height: 48px;
  margin-block-end: 0.5rem;
}

/* ── Empty State ─────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1.5rem;
  text-align: center;
  color: var(--text-2);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-block: 1rem;
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-block-end: 1rem;
  color: var(--text-3);
}

.empty-state-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin-block-end: 0.5rem;
}

.empty-state-desc {
  max-width: 360px;
  margin-block-end: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.5;
}

.empty-state svg { margin-block-end: 1rem; opacity: 0.4; }
.empty-state p { margin-block-end: 1rem; }

/* ── Pagination ──────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  margin-block-start: 1.5rem;
}

.pagination-btn {
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all var(--transition);
}

.pagination-btn:hover { background: var(--surface-2); color: var(--text); }
.pagination-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Drag & Drop Zone ────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.drop-zone svg { margin-block-end: 0.75rem; opacity: 0.5; }
.drop-zone p { color: var(--text-2); font-size: 0.875rem; }

/* ── ETC Brand Components & Theme Toggle ─────────────────────────── */
.brand-logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-logo-img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
  transition: transform var(--transition);
  background: #ffffff;
  border-radius: 8px;
  padding: 2px;
}

.brand-logo-container:hover .brand-logo-img {
  transform: scale(1.05);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent);
  font-family: 'Times New Roman', 'Cinzel', serif;
}

.brand-sub {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--brand-green);
  text-transform: uppercase;
}

/* ── Theme Toggle Button ─────────────────────────────────────────── */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
}

.theme-toggle-btn:hover {
  background: var(--surface-3);
  border-color: var(--accent);
  color: var(--accent);
  transform: rotate(15deg);
}

/* ── Auth Screen Branding ────────────────────────────────────────── */
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-block-end: 1.75rem;
}

.auth-logo-img {
  width: 105px;
  height: 105px;
  object-fit: contain;
  margin-block-end: 0.75rem;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.12));
  background: #ffffff;
  border-radius: 12px;
  padding: 4px;
}

.auth-brand-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent);
  font-family: 'Times New Roman', 'Cinzel', serif;
  letter-spacing: 0.05em;
  line-height: 1;
}

.auth-brand-subtitle {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--brand-green);
  text-transform: uppercase;
  margin-block-start: 0.35rem;
}

.auth-brand-domain {
  font-size: 0.8125rem;
  color: var(--text-2);
  margin-block-start: 0.5rem;
  text-decoration: none;
  transition: color var(--transition);
}

.auth-brand-domain:hover {
  color: var(--accent);
}

.auth-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 440px;
  margin-block-end: 1rem;
}

