/* ============================================================
   journal.css — Dark Financial Terminal Aesthetic
   Miami Options Trading — Trading Journal Module
   ============================================================ */

/* --- Google Fonts (loaded via HTML <link>) ---------------------- */
/* JetBrains Mono — numbers, tickers
   DM Sans        — UI labels, body text                           */

/* --- CSS Variables --------------------------------------------- */
:root {
  --bg-base:       #0D0F14;
  --bg-card:       #161B27;
  --bg-card-hover: #1C2436;
  --bg-nav:        #0A0C11;
  --border:        #252D40;
  --border-light:  #2E3850;

  --green:         #00FF88;
  --green-dim:     rgba(0, 255, 136, 0.15);
  --red:           #FF3B5C;
  --red-dim:       rgba(255, 59, 92, 0.15);
  --gold:          #F0C040;
  --gold-dim:      rgba(240, 192, 64, 0.15);
  --blue-accent:   #4E9BFF;

  --text-primary:  #E8EDF5;
  --text-secondary:#8B95A8;
  --text-muted:    #4A5568;

  --font-mono:     'JetBrains Mono', 'IBM Plex Mono', 'Courier New', monospace;
  --font-ui:       'DM Sans', 'Inter', -apple-system, sans-serif;

  --radius-sm:     4px;
  --radius-md:     8px;
  --radius-lg:     12px;
  --radius-full:   9999px;

  --shadow-card:   0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow-green: 0 0 12px rgba(0, 255, 136, 0.2);
  --shadow-glow-red:   0 0 12px rgba(255, 59, 92, 0.2);
}

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

body {
  font-family: var(--font-ui);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  /* subtle scanline texture */
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255,255,255,0.012) 2px,
      rgba(255,255,255,0.012) 4px
    );
}

a { color: var(--blue-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Auth Pages ------------------------------------------------- */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(0,255,136,0.04) 0%, transparent 60%),
    repeating-linear-gradient(
      0deg, transparent, transparent 2px,
      rgba(255,255,255,0.012) 2px, rgba(255,255,255,0.012) 4px
    );
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-card);
}

.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo img { filter: brightness(1.1); }

.auth-title {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 600;
  text-align: center;
  color: var(--green);
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.75rem;
}

.auth-footer-text {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 1.25rem;
}

.auth-footer-text a {
  color: var(--green);
  font-weight: 600;
}

/* --- Forms ----------------------------------------------------- */
.form-group {
  margin-bottom: 1.1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 0.6rem 0.85rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(0, 255, 136, 0.15);
}

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

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238B95A8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.form-group select option {
  background: var(--bg-card);
}

.field-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.required { color: var(--red); }
.optional { color: var(--text-muted); font-weight: 400; }

/* Radio group */
.radio-group {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.radio-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.15s;
  font-family: var(--font-mono);
}

.radio-option input[type="radio"] { display: none; }

.radio-option.win {
  color: var(--green);
  border-color: rgba(0,255,136,0.3);
}
.radio-option.loss {
  color: var(--red);
  border-color: rgba(255,59,92,0.3);
}
.radio-option input[type="radio"]:checked + span,
.radio-option.selected {
  /* handled via JS */
}
.radio-option.win.selected,
.radio-option.win input[type="radio"]:checked ~ * {
  background: var(--green-dim);
  border-color: var(--green);
  box-shadow: var(--shadow-glow-green);
}
.radio-option.loss.selected {
  background: var(--red-dim);
  border-color: var(--red);
  box-shadow: var(--shadow-glow-red);
}

/* --- Buttons --------------------------------------------------- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--green);
  color: #0D0F14;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.15s, box-shadow 0.15s;
  text-decoration: none;
}

.btn-primary:hover {
  opacity: 0.88;
  box-shadow: var(--shadow-glow-green);
  text-decoration: none;
  color: #0D0F14;
}

.btn-danger {
  background: var(--red);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
}
.btn-danger:hover { opacity: 0.85; text-decoration: none; color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  text-decoration: none;
}
.btn-ghost:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
  text-decoration: none;
}

.btn-full { width: 100%; margin-top: 0.5rem; }

/* --- Alerts ---------------------------------------------------- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.alert p { margin: 0; line-height: 1.5; }
.alert p + p { margin-top: 0.25rem; }

.alert-error {
  background: var(--red-dim);
  border: 1px solid rgba(255,59,92,0.4);
  color: #ff8fa0;
}

.alert-success {
  background: var(--green-dim);
  border: 1px solid rgba(0,255,136,0.3);
  color: var(--green);
}

/* --- Journal Layout -------------------------------------------- */
.journal-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Navigation ------------------------------------------------ */
.journal-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.nav-brand img { height: 32px; }

.nav-brand-text {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--green);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
}

.nav-links a {
  display: block;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-primary);
  background: rgba(255,255,255,0.06);
}

.nav-links a.active {
  color: var(--green);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.nav-username {
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.nav-username span { color: var(--gold); font-weight: 600; }

.nav-logout {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  text-decoration: none;
}
.nav-logout:hover {
  color: var(--red);
  border-color: rgba(255,59,92,0.4);
  background: var(--red-dim);
  text-decoration: none;
}

/* --- Main Content ---------------------------------------------- */
.journal-main {
  flex: 1;
  padding: 2rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-title {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* --- Summary Cards --------------------------------------------- */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-card);
}

.summary-card-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.summary-card-value {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.1;
}

.summary-card-value.positive { color: var(--green); }
.summary-card-value.negative { color: var(--red); }
.summary-card-value.neutral  { color: var(--gold); }
.summary-card-value.blue     { color: var(--blue-accent); }

.summary-card-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  font-family: var(--font-mono);
}

/* --- Date Picker Bar ------------------------------------------- */
.date-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.date-controls input[type="date"],
.date-controls input[type="month"],
.date-controls select {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.date-controls input:focus,
.date-controls select:focus {
  outline: none;
  border-color: var(--green);
}

/* Chrome date input icon color */
.date-controls input[type="date"]::-webkit-calendar-picker-indicator,
.date-controls input[type="month"]::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
  cursor: pointer;
}

/* --- Trades Table ---------------------------------------------- */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

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

.trades-table th {
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
}

.trades-table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}

.trades-table tr:last-child td { border-bottom: none; }

.trades-table tbody tr {
  transition: background 0.12s;
}

.trades-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

.trades-table .col-ticker {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}

.trades-table .col-amount {
  font-family: var(--font-mono);
  font-weight: 600;
}

.trades-table .col-amount.positive { color: var(--green); }
.trades-table .col-amount.negative { color: var(--red); }

.trades-table .col-notes {
  color: var(--text-secondary);
  font-size: 0.82rem;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trades-table .col-actions {
  white-space: nowrap;
}

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem !important;
  font-size: 0.9rem;
}

/* Row color-coding for daily/monthly summaries */
.row-win  { border-left: 3px solid var(--green); }
.row-loss { border-left: 3px solid var(--red); }
.row-neutral { border-left: 3px solid var(--border); }
.row-total {
  background: rgba(240, 192, 64, 0.07) !important;
  font-weight: 700;
  border-top: 1px solid rgba(240,192,64,0.25) !important;
}

/* --- Badges ---------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-win {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(0,255,136,0.3);
}

.badge-loss {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255,59,92,0.3);
}

.badge-type {
  background: rgba(78,155,255,0.12);
  color: var(--blue-accent);
  border: 1px solid rgba(78,155,255,0.25);
}

/* --- Modal ----------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(3px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
  position: relative;
}

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

.modal-title {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--green);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text-primary); }

/* --- Chart Area ------------------------------------------------ */
.chart-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-card);
}

.chart-title {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

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

.chart-container-sm {
  position: relative;
  height: 180px;
}

/* Two-column chart grid */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.charts-grid-equal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

@media (max-width: 768px) {
  .charts-grid,
  .charts-grid-equal {
    grid-template-columns: 1fr;
  }
}

/* --- Section Divider ------------------------------------------- */
.section-divider {
  height: 1px;
  background: linear-gradient(to right, var(--border), transparent);
  margin: 1.75rem 0;
}

/* --- Pagination / Selector Row --------------------------------- */
.view-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.view-controls label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--text-secondary);
  text-decoration: none;
}

/* --- Edit/Delete Page ------------------------------------------ */
.trade-form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 560px;
  margin: 0 auto;
  box-shadow: var(--shadow-card);
}

.trade-form-card h2 {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.delete-zone {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.delete-zone p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* --- Confirm dialog (inline) ----------------------------------- */
.confirm-box {
  display: none;
  background: var(--red-dim);
  border: 1px solid rgba(255,59,92,0.35);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 0.75rem;
}

.confirm-box p {
  color: #ff8fa0;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

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

/* --- Responsive ------------------------------------------------ */
@media (max-width: 768px) {
  .journal-nav { padding: 0 1rem; }
  .nav-links { display: none; }
  .journal-main { padding: 1.25rem 1rem; }
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
  .summary-card-value { font-size: 1.3rem; }
  .trades-table .col-notes { display: none; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .summary-cards { grid-template-columns: 1fr 1fr; }
  .modal-box { padding: 1.25rem; }
  .auth-card { padding: 1.75rem 1.25rem; }
}
