/* ==========================================================================
   CUEVANCE Components Styles - Time & Duration Calculator
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Retro LCD Dual-Row Display
   -------------------------------------------------------------------------- */
.lcd-monitor-card {
  background-color: var(--lcd-bg);
  border: 1px solid var(--lcd-border);
  box-shadow: var(--lcd-shadow);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
  user-select: none;
  flex-shrink: 0;
}

/* Subtle scanlines effect */
.lcd-monitor-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%),
              linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
  background-size: 100% 3px, 6px 100%;
  pointer-events: none;
  opacity: 0.6;
}

.lcd-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  height: 20px;
  min-height: 20px;
  max-height: 20px;
  margin-bottom: 0px;
  box-sizing: border-box;
  overflow: hidden;
}

.lcd-badge-tag {
  background: var(--bg-card-border);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-size: 9px;
}

/* Upper Result Unit Selector Pills */
.lcd-upper-unit-selector {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(0, 0, 0, 0.35);
  padding: 1px 3px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-upper-unit-pill {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth);
}

.btn-upper-unit-pill:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.btn-upper-unit-pill.upper-unit-active {
  background: var(--accent-cyan);
  color: var(--accent-on-cyan);
  box-shadow: 0 0 6px var(--accent-cyan-glow);
  font-weight: 800;
}

.btn-cycle-upper-unit {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 2px;
  transition: all var(--duration-fast) var(--ease-smooth);
}

.btn-cycle-upper-unit:hover {
  border-color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.08);
}

.lcd-unit-badge {
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 9.5px;
}

/* Upper Row (RESULT) */
.lcd-upper-container {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  min-height: clamp(46px, 12.5vw, 58px);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast) var(--ease-smooth);
  box-sizing: border-box;
  padding: 2px 0;
}

.lcd-upper-container:hover {
  background: rgba(255, 255, 255, 0.02);
}

.lcd-slot-group {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "zero" 0;
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
  line-height: 1.1;
}

.lcd-slot-group.lcd-upper {
  font-size: clamp(38px, 11.5vw, 55px);
  font-weight: 700;
  color: var(--lcd-upper-text);
  text-shadow: var(--lcd-upper-shadow);
  letter-spacing: 0.02em;
}

/* Lower Row (ENTRY) */
.lcd-lower-container {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  min-height: clamp(32px, 8.8vw, 42px);
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  padding-top: 4px;
  box-sizing: border-box;
}

.lcd-slot-group.lcd-lower {
  font-size: clamp(26px, 7.9vw, 38px);
  font-weight: 600;
  color: var(--lcd-lower-text);
  text-shadow: var(--lcd-lower-shadow);
  letter-spacing: 0.02em;
}

/* Fixed Width Slot Elements - Strict tabular widths with zero shifting */
.lcd-slot-sign {
  display: inline-block;
  width: 1.1ch;
  min-width: 1.1ch;
  max-width: 1.1ch;
  text-align: center;
  font-family: var(--font-mono);
  opacity: 0;
}

.lcd-slot-sign.active {
  opacity: 1;
}

.lcd-slot-num {
  display: inline-block;
  text-align: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1;
}

.lcd-slot-hh,
.lcd-slot-mm,
.lcd-slot-ss {
  width: 2ch;
  min-width: 2ch;
  max-width: 2ch;
}

.lcd-slot-frac {
  width: 3ch;
  min-width: 3ch;
  max-width: 3ch;
  font-size: 0.85em;
  opacity: 0.9;
}

.lcd-slot-sep {
  display: inline-block;
  width: 0.7ch;
  min-width: 0.7ch;
  max-width: 0.7ch;
  text-align: center;
  opacity: 0.7;
  font-family: var(--font-mono);
}

.lcd-numeric-group {
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
}

.lcd-numeric-group .lcd-slot-numeric {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1;
  text-align: right;
  letter-spacing: 0.02em;
}

.lcd-numeric-group .lcd-slot-unit {
  display: inline-block;
  min-width: 2.5ch;
  font-size: 0.75em;
  margin-left: 4px;
  color: var(--text-muted);
  text-align: left;
}

.lcd-op-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  min-width: 18px;
  max-width: 18px;
  height: 18px;
  min-height: 18px;
  max-height: 18px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent-orange);
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-xs);
  margin-right: 4px;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-smooth);
  box-sizing: border-box;
}

.lcd-op-indicator.active {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   2. Unit Selector Direct Bar
   -------------------------------------------------------------------------- */
.unit-selector-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  flex-shrink: 0;
}

.btn-unit-pill {
  padding: 6px 2px;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: center;
  transition: all var(--duration-fast) var(--ease-smooth);
}

.btn-unit-pill:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent-cyan);
}

.btn-unit-pill.unit-active {
  background: var(--accent-cyan);
  color: var(--accent-on-cyan);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan-glow);
  font-weight: 800;
}

/* --------------------------------------------------------------------------
   3. Keypad Matrix
   -------------------------------------------------------------------------- */
.calculator-keypad-matrix {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(6, 44px);
  gap: 6px;
  align-content: start;
}

@media (max-width: 600px) {
  .calculator-keypad-matrix {
    grid-template-rows: repeat(6, auto);
    gap: 6px;
    flex: initial;
    align-content: start;
  }
}

.btn-calc-key {
  height: 44px;
  border-radius: var(--radius-sm);
  font-size: 19px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-smooth);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

@media (max-width: 600px) {
  .btn-calc-key {
    height: clamp(42px, 5.6vh, 50px);
    min-height: 40px;
    font-size: clamp(17px, 4.8vw, 21px);
  }
}

.btn-calc-key.btn-calc-span-2 {
  grid-column: span 2;
}

.btn-calc-key:active {
  transform: scale(0.96);
}

/* Key Colors */
.btn-calc-num {
  background: var(--key-num-bg);
  border: 1px solid var(--key-num-border);
  color: var(--key-num-text);
  font-family: var(--font-mono);
}

.btn-calc-num:hover {
  background: var(--key-num-hover);
}

.btn-calc-op {
  background: var(--key-op-bg);
  border: 1px solid var(--key-op-border);
  color: var(--key-op-text);
  font-size: clamp(18px, 5.0vw, 22px);
}

.btn-calc-op:hover {
  background: var(--key-op-hover);
}

.btn-calc-action {
  background: var(--key-action-bg);
  border: 1px solid var(--key-action-border);
  color: var(--key-action-text);
  font-size: var(--text-xs);
  font-weight: 800;
}

.btn-calc-action:hover {
  color: var(--text-primary);
}

.btn-calc-eval {
  background: var(--key-eval-bg);
  border: 1px solid var(--key-eval-border);
  color: var(--key-eval-text);
  font-size: clamp(18px, 5.0vw, 22px);
  box-shadow: var(--key-eval-shadow);
}

.btn-calc-eval:hover {
  filter: brightness(1.1);
}

/* --------------------------------------------------------------------------
   4. FPS Header Trigger & Modal Selector
   -------------------------------------------------------------------------- */
.btn-fps-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth);
}

.btn-fps-trigger:hover {
  border-color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.08);
}

.fps-trigger-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.fps-trigger-val {
  font-family: var(--font-mono);
  font-weight: 800;
}

.fps-trigger-arrow {
  font-size: 8px;
  opacity: 0.7;
}

/* FPS Selector Modal / Bottom Sheet */
.fps-modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-smooth);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

@media (min-width: 500px) {
  .fps-modal-backdrop {
    align-items: center;
  }
}

.fps-modal-backdrop.modal-open {
  opacity: 1;
  pointer-events: auto;
}

.fps-modal-sheet {
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform var(--duration-normal) var(--ease-spring);
  padding: 16px;
  box-sizing: border-box;
}

@media (min-width: 500px) {
  .fps-modal-sheet {
    border-radius: var(--radius-lg);
    transform: scale(0.95);
  }
}

.fps-modal-backdrop.modal-open .fps-modal-sheet {
  transform: translateY(0);
}

@media (min-width: 500px) {
  .fps-modal-backdrop.modal-open .fps-modal-sheet {
    transform: scale(1);
  }
}

.fps-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--bg-card-border);
  margin-bottom: 10px;
}

.fps-modal-title {
  font-size: var(--text-sm);
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

.fps-modal-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.fps-options-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 55vh;
  padding-right: 2px;
}

.fps-option-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.fps-option-item:hover {
  border-color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.05);
}

.fps-option-item.fps-active {
  border-color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.12);
  box-shadow: 0 0 8px var(--accent-cyan-glow);
}

.fps-option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fps-option-name {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-primary);
}

.fps-option-desc {
  font-size: 10px;
  color: var(--text-muted);
}

.fps-option-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  color: var(--accent-cyan);
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

/* --------------------------------------------------------------------------
   5. History Tab Components
   -------------------------------------------------------------------------- */
.history-controls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0;
  flex-shrink: 0;
}

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

.btn-history-action {
  padding: 5px 10px;
  font-size: var(--text-2xs);
  font-weight: 700;
  border-radius: var(--radius-xs);
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  color: var(--text-secondary);
  transition: all var(--duration-fast);
}

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

.history-summary-bar {
  background: var(--bg-card);
  border: 1px solid var(--accent-cyan-glow);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-sum-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
}

.history-sum-value {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--accent-cyan);
}

.history-list-scroll {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.history-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: border-color var(--duration-fast);
}

.history-card:hover {
  border-color: var(--accent-cyan);
}

.history-card-selected {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.08);
}

.history-card-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.history-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.history-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.history-formula {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-result-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.history-result-val {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
}

.history-timestamp {
  font-size: 9px;
  color: var(--text-dim);
}

.history-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-history-tool {
  padding: 4px 8px;
  font-size: var(--text-2xs);
  font-weight: 700;
  border-radius: var(--radius-xs);
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  color: var(--text-muted);
  transition: all var(--duration-fast);
}

.btn-history-tool:hover {
  color: var(--text-primary);
  border-color: var(--accent-cyan);
}

.history-empty-message {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-dim);
  font-size: var(--text-xs);
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   6. Hamburger Drawer & Modals
   -------------------------------------------------------------------------- */
.btn-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  gap: 4px;
  padding: 8px;
}

.hamburger-line {
  width: 18px;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 2px;
  transition: all var(--duration-fast);
}

.drawer-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-smooth);
}

.drawer-backdrop.drawer-open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 320px;
  max-width: 85vw;
  background: var(--bg-card);
  border-left: 1px solid var(--bg-card-border);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--duration-normal) var(--ease-spring);
  padding: 20px;
  backdrop-filter: blur(20px);
}

.drawer-backdrop.drawer-open .drawer-panel {
  transform: translateX(0);
}

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

.drawer-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.btn-modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-md);
}

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

.drawer-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  flex: 1;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-section-label {
  font-size: var(--text-2xs);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.lang-switch-group, .theme-switch-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

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

.btn-lang-tab, .btn-theme-tab {
  padding: 8px;
  font-size: var(--text-xs);
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  color: var(--text-secondary);
  text-align: center;
}

.btn-lang-tab.lang-active, .btn-theme-tab.theme-active {
  background: var(--accent-cyan);
  color: var(--accent-on-cyan);
  border-color: var(--accent-cyan);
}

.drawer-action-btn {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-decoration: none;
}

.drawer-action-btn:hover {
  border-color: var(--accent-cyan);
}

.drawer-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--bg-card-border);
  display: flex;
  justify-content: space-between;
  font-size: var(--text-2xs);
  color: var(--text-dim);
}

/* --------------------------------------------------------------------------
   7. Toast Notifications
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent-cyan);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 12px var(--accent-cyan-glow);
  font-size: var(--text-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(16px);
  transition: all var(--duration-normal) var(--ease-spring);
}

.toast.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.toast-error {
  border-color: var(--accent-rose);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 12px rgba(251, 113, 133, 0.4);
}

/* --------------------------------------------------------------------------
   8. Super-Compact Height Optimizations (Small Phones / Embedded Frames)
   -------------------------------------------------------------------------- */
@media (max-height: 680px) {
  .app-container {
    padding: 4px 8px 6px;
  }
  .top-header {
    padding: 1px 2px 4px;
    margin-bottom: 4px;
  }
  .tab-navigation {
    margin-bottom: 4px;
    padding: 2px;
  }
  .btn-nav-tab {
    padding: 4px 8px;
    font-size: 10.5px;
  }
  .lcd-monitor-card {
    padding: 6px 10px;
    gap: 2px;
  }
  .lcd-upper-container {
    height: 32px;
    min-height: 32px;
    max-height: 32px;
  }
  .lcd-slot-group.lcd-upper {
    font-size: 20px;
  }
  .lcd-lower-container {
    height: 24px;
    min-height: 24px;
    max-height: 24px;
    padding-top: 2px;
  }
  .lcd-slot-group.lcd-lower {
    font-size: 14px;
  }
  .unit-selector-bar {
    gap: 3px;
  }
  .btn-unit-pill {
    padding: 4px 2px;
    font-size: 10px;
  }
  .calculator-keypad-matrix {
    gap: 4px;
  }
  .btn-calc-key {
    min-height: 32px;
    max-height: 40px;
    font-size: 16px;
  }
  .app-footer {
    padding-top: 4px;
  }
}
