/* ============================================================
   BelloBark Buchhaltung — Component Styles
   All colors via CSS custom properties (see themes.css)
   ============================================================ */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ============================================================
   Background Effects
   ============================================================ */

/* -- Gradient Orbs -- */
.bg-orbs {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  overflow: hidden;
  display: none;
}
[data-theme="gradient"] .bg-orbs { display: block; }

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(160px);
  opacity: .55;
  will-change: transform;
}
.bg-orb--1 {
  width: 600px; height: 600px;
  background: #7c5cfc;
  top: -10%; left: -5%;
  animation: orb-drift-1 22s ease-in-out infinite alternate;
}
.bg-orb--2 {
  width: 500px; height: 500px;
  background: #ff9f43;
  top: 40%; right: -10%;
  animation: orb-drift-2 26s ease-in-out infinite alternate;
}
.bg-orb--3 {
  width: 450px; height: 450px;
  background: #ff6b81;
  bottom: -10%; left: 30%;
  animation: orb-drift-3 20s ease-in-out infinite alternate;
}

@keyframes orb-drift-1 {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(80px, 60px) scale(1.15); }
}
@keyframes orb-drift-2 {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-60px, -80px) scale(1.1); }
}
@keyframes orb-drift-3 {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, -50px) scale(1.2); }
}

/* -- Noise Overlay -- */
.bg-noise {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0;
}
[data-theme="gradient"] .bg-noise {
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 128px 128px;
}

/* -- Terminal Scanlines -- */
.bg-scanlines {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  display: none;
}
[data-theme="terminal"] .bg-scanlines {
  display: block;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,.15) 2px,
    rgba(0,0,0,.15) 4px
  );
  opacity: .4;
}

/* -- Terminal Green Glow -- */
.bg-glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  display: none;
}
[data-theme="terminal"] .bg-glow {
  display: block;
  background: radial-gradient(ellipse at 50% 40%, rgba(51,255,136,.07) 0%, transparent 70%);
}

/* ============================================================
   Layout
   ============================================================ */

.app-wrapper {
  position: relative; z-index: 2;
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem 6rem;
}

/* ---- Header ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.app-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}
.app-title span {
  color: var(--text-sub);
  font-weight: 400;
}

[data-theme="terminal"] .app-title {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 1.1rem;
}
[data-theme="terminal"] .app-title::before {
  content: "> ";
  color: var(--accent-2);
}

[data-theme="editorial"] .app-title {
  font-size: 1.5rem;
  font-style: italic;
  letter-spacing: .01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.year-select {
  font-family: var(--font-mono);
  font-size: .85rem;
  padding: .4rem .8rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-input);
  border-radius: 8px;
  cursor: pointer;
  outline: none;
  transition: background .15s, border-color .15s;
}
.year-select:focus {
  background: var(--bg-input-focus);
  border-color: var(--accent-2);
}
[data-theme="terminal"] .year-select { border-radius: 0; }
[data-theme="bento"] .year-select { border-radius: 12px; }

/* ============================================================
   Tab Navigation
   ============================================================ */

.tab-nav {
  display: flex;
  gap: 2px;
  margin-bottom: 2rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  font-family: var(--font);
  font-size: .9rem;
  padding: .65rem 1.1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-sub);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}
.tab-btn:hover {
  color: var(--text);
}
.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent-2);
}

/* Terminal: monospace + green underline */
[data-theme="terminal"] .tab-btn {
  font-family: var(--font-mono);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}
[data-theme="terminal"] .tab-btn.active {
  border-bottom-color: var(--accent-2);
  text-shadow: 0 0 8px rgba(51,255,136,.3);
}

/* Bento: rounded pill tabs */
[data-theme="bento"] .tab-nav {
  border-bottom: none;
  gap: 6px;
  padding: 4px;
  background: rgba(26,23,21,.04);
  border-radius: 14px;
}
[data-theme="bento"] .tab-btn {
  border-bottom: none;
  border-radius: 10px;
  padding: .55rem 1rem;
}
[data-theme="bento"] .tab-btn.active {
  background: var(--bg-card);
  color: var(--accent-2);
  box-shadow: 0 1px 4px rgba(26,23,21,.08);
}

/* Editorial: serif + thin line */
[data-theme="editorial"] .tab-btn {
  font-family: var(--font);
  font-size: .95rem;
  letter-spacing: .03em;
}
[data-theme="editorial"] .tab-btn.active {
  border-bottom-width: 1px;
  border-bottom-color: var(--accent-2);
}

/* ============================================================
   Tab Content
   ============================================================ */

.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
  animation: tab-fade-in .2s ease;
}

@keyframes tab-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   KPI Cards
   ============================================================ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.25rem 1rem;
  box-shadow: var(--card-shadow);
  transition: background .15s, transform .15s;
}
.kpi-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

/* Gradient: frosted glass */
[data-theme="gradient"] .kpi-card {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.kpi-label {
  font-size: .75rem;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .4rem;
}

[data-theme="editorial"] .kpi-label {
  text-transform: none;
  letter-spacing: .02em;
  font-style: italic;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}
.kpi-value.income  { color: var(--color-income); }
.kpi-value.expense { color: var(--color-expense); }

/* ============================================================
   Forms
   ============================================================ */

.entry-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--card-shadow);
}

[data-theme="gradient"] .entry-form {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  flex: 1;
  min-width: 130px;
}

.form-group label {
  font-size: .75rem;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: .04em;
}

[data-theme="editorial"] .form-group label {
  text-transform: none;
  font-style: italic;
  letter-spacing: .01em;
}

.form-group input,
.form-group select {
  font-family: var(--font);
  font-size: .88rem;
  padding: .5rem .7rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-input);
  border-radius: 8px;
  outline: none;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group select:focus {
  background: var(--bg-input-focus);
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(124,92,252,.12);
}

[data-theme="terminal"] .form-group input,
[data-theme="terminal"] .form-group select {
  font-family: var(--font-mono);
  border-radius: 0;
  border-style: solid;
}
[data-theme="terminal"] .form-group input:focus,
[data-theme="terminal"] .form-group select:focus {
  box-shadow: 0 0 0 2px rgba(51,255,136,.15);
}

[data-theme="bento"] .form-group input,
[data-theme="bento"] .form-group select {
  border-radius: 12px;
}

.form-submit {
  flex: 0 0 auto;
  min-width: auto;
  justify-content: flex-end;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 600;
  padding: .5rem 1.1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }

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

/* Terminal: primary button text is black for contrast */
[data-theme="terminal"] .btn-primary {
  color: #0a0a0a;
  font-family: var(--font-mono);
  border-radius: 0;
  text-transform: uppercase;
  letter-spacing: .04em;
}

[data-theme="bento"] .btn {
  border-radius: 12px;
}

[data-theme="editorial"] .btn {
  border-radius: 6px;
  letter-spacing: .02em;
}

.btn-danger {
  background: transparent;
  color: var(--btn-danger);
  font-size: .78rem;
  padding: .3rem .6rem;
  border: 1px solid var(--btn-danger);
  opacity: .6;
}
.btn-danger:hover {
  background: var(--btn-danger);
  color: #fff;
  opacity: 1;
}

.btn-ghost {
  background: transparent;
  color: var(--text-sub);
  border: 1px solid var(--border);
  padding: .35rem .7rem;
}
.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text);
}

/* ============================================================
   Filter Row
   ============================================================ */

.filter-row {
  display: flex;
  gap: .75rem;
  margin-bottom: 1rem;
  align-items: center;
}

.filter-row select {
  font-family: var(--font);
  font-size: .85rem;
  padding: .4rem .8rem;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-input);
  border-radius: 8px;
  outline: none;
  cursor: pointer;
}
.filter-row select:focus {
  border-color: var(--accent-2);
}

[data-theme="terminal"] .filter-row select {
  font-family: var(--font-mono);
  border-radius: 0;
}
[data-theme="bento"] .filter-row select { border-radius: 12px; }

/* ============================================================
   Tables
   ============================================================ */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 2rem;
  border-radius: var(--card-radius);
  border: 1px solid var(--border);
}

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

.data-table th {
  background: var(--bg-table-header);
  padding: .7rem .8rem;
  text-align: left;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-sub);
  border-bottom: 1px solid var(--border);
}

[data-theme="editorial"] .data-table th {
  text-transform: none;
  font-style: italic;
  font-weight: 400;
  letter-spacing: .02em;
}

[data-theme="terminal"] .data-table th {
  font-family: var(--font-mono);
  font-size: .75rem;
}

.data-table td {
  padding: .6rem .8rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background .1s;
}
.data-table tbody tr:hover {
  background: var(--bg-table-row-hover);
}

.data-table tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--border);
  border-bottom: none;
  padding: .7rem .8rem;
}

.data-table .income  { color: var(--color-income); }
.data-table .expense { color: var(--color-expense); }

/* For profit that can be positive or negative */
.profit-pos { color: var(--color-profit-pos); }
.profit-neg { color: var(--color-profit-neg); }

/* ============================================================
   Homeoffice Calendar
   ============================================================ */

.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.month-nav span {
  font-size: 1.1rem;
  font-weight: 600;
  min-width: 160px;
  text-align: center;
}

[data-theme="editorial"] .month-nav span {
  font-style: italic;
}

.ho-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 1.5rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.ho-weekday {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-dim);
  text-align: center;
  padding: .4rem 0;
}

.ho-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  font-family: var(--font-mono);
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  color: var(--text);
  background: var(--bg-card);
}
.ho-day:hover {
  background: var(--bg-card-hover);
  border-color: var(--border);
}

.ho-day.active {
  background: var(--accent-2);
  color: #fff;
  border-color: var(--accent-2);
  font-weight: 700;
}
[data-theme="terminal"] .ho-day.active {
  color: #0a0a0a;
}

.ho-day.other-month {
  color: var(--text-dim);
  opacity: .4;
  cursor: default;
}
.ho-day.empty {
  background: transparent;
  border: none;
  cursor: default;
}

[data-theme="terminal"] .ho-day { border-radius: 0; }
[data-theme="bento"] .ho-day { border-radius: 12px; }

.ho-info {
  text-align: center;
  font-size: 1.05rem;
  color: var(--text-sub);
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
}
.ho-info span {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-2);
}

/* ============================================================
   Section Title
   ============================================================ */

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
  margin-top: .5rem;
}
.section-title span {
  color: var(--text-sub);
  font-weight: 400;
}

[data-theme="editorial"] .section-title {
  font-style: italic;
  font-weight: 400;
  font-size: 1.1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .5rem;
}

/* ============================================================
   EÜR
   ============================================================ */

.euer-summary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
  margin-bottom: 2rem;
  box-shadow: var(--card-shadow);
}

[data-theme="gradient"] .euer-summary {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.euer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .6rem 0;
  font-size: .95rem;
}
.euer-row + .euer-row {
  border-top: 1px solid var(--border);
}

.euer-row .income  { color: var(--color-income); font-family: var(--font-mono); font-weight: 600; }
.euer-row .expense { color: var(--color-expense); font-family: var(--font-mono); font-weight: 600; }

.euer-total {
  font-size: 1.15rem;
  font-weight: 700;
  border-top: 2px solid var(--border) !important;
  padding-top: .8rem !important;
}
.euer-total span:last-child {
  font-family: var(--font-mono);
}

.euer-hint {
  font-size: .8rem;
  color: var(--text-dim);
  margin-top: 1.5rem;
  margin-bottom: .75rem;
}

/* ============================================================
   Theme Switcher
   ============================================================ */

.switcher {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(30,30,30,.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
}

.switcher-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
  transition: transform .15s, border-color .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  padding: 0;
}
.switcher-btn:hover {
  transform: scale(1.12);
}
.switcher-btn.active {
  border-color: #fff;
}

.switcher-btn .sw-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.switcher-btn[data-theme="gradient"] .sw-icon {
  background: linear-gradient(135deg, #7c5cfc, #ff9f43);
}
.switcher-btn[data-theme="terminal"] .sw-icon {
  background: #33ff88;
}
.switcher-btn[data-theme="bento"] .sw-icon {
  background: linear-gradient(135deg, #f5f0eb, #e8821c);
}
.switcher-btn[data-theme="editorial"] .sw-icon {
  background: linear-gradient(135deg, #8b7ec8, #e8e4de);
}

/* Tooltip */
.switcher-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(.9);
  font-size: .7rem;
  font-family: var(--font);
  white-space: nowrap;
  padding: 3px 8px;
  background: rgba(0,0,0,.85);
  color: #fff;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s, transform .15s;
}
.switcher-btn:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 700px) {
  .app-wrapper {
    padding: 1.25rem 1rem 5rem;
  }

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

  .form-row {
    flex-direction: column;
  }
  .form-group {
    min-width: 100%;
  }

  .table-wrap {
    margin-left: -.5rem;
    margin-right: -.5rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .ho-calendar {
    gap: 3px;
  }

  .kpi-value {
    font-size: 1.2rem;
  }

  .app-title {
    font-size: 1.1rem;
  }
}

/* ============================================================
   Utility
   ============================================================ */

.income  { color: var(--color-income); }
.expense { color: var(--color-expense); }

/* Delete button in table cells */
.data-table .btn-danger {
  font-size: .72rem;
  padding: .2rem .5rem;
}

/* Scrollbar styling for dark themes */
[data-theme="gradient"] ::-webkit-scrollbar,
[data-theme="terminal"] ::-webkit-scrollbar,
[data-theme="editorial"] ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
[data-theme="gradient"] ::-webkit-scrollbar-track,
[data-theme="terminal"] ::-webkit-scrollbar-track,
[data-theme="editorial"] ::-webkit-scrollbar-track {
  background: transparent;
}
[data-theme="gradient"] ::-webkit-scrollbar-thumb,
[data-theme="terminal"] ::-webkit-scrollbar-thumb,
[data-theme="editorial"] ::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Date input color-scheme for dark themes */
[data-theme="gradient"] input[type="date"],
[data-theme="terminal"] input[type="date"],
[data-theme="editorial"] input[type="date"] {
  color-scheme: dark;
}
[data-theme="bento"] input[type="date"] {
  color-scheme: light;
}

/* Select arrow color */
select {
  appearance: auto;
}
