/* Tithi Devathai Calculator - Style System with Custom Calendar & Custom Timezone Dropdown */

:root, [data-theme="light"] {
  --color-scheme: light;
  
  --font-heading: 'Cinzel', serif, system-ui;
  --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  --purple-primary: #5c3577;
  --purple-dark: #3c1e52;
  --purple-light: #f3ebf8;
  --purple-glow: rgba(92, 53, 119, 0.15);
  
  --emerald-primary: #2d7356;
  --emerald-dark: #1b4d38;
  --emerald-light: #eaf6f0;
  
  --gold-accent: #c49a45;
  --gold-light: #fcf8ee;
  
  --bg-gradient: linear-gradient(135deg, #f8f4fa 0%, #edf6f1 100%);
  --card-bg: #ffffff;
  --card-border: #e6dfeb;
  --card-shadow: 0 16px 40px rgba(50, 30, 65, 0.07);
  --result-bg: linear-gradient(135deg, #f5eef9 0%, #ebf6f0 100%);
  --result-card-bg: #ffffff;
  
  --ink-primary: #1e1726;
  --ink-muted: #696073;
  --line-border: #ebdff0;
  
  --input-bg: #ffffff;
  --input-border: #e0d5e6;
  --input-border-hover: #a27cbd;
  --input-text: #1e1726;
  --input-placeholder: #a49aa9;
  
  --error-color: #d93025;
  --error-bg: rgba(217, 48, 37, 0.08);
  --error-border: rgba(217, 48, 37, 0.3);
  --error-glow: rgba(217, 48, 37, 0.2);
  
  --note-bg: #fdf9f0;
  --note-border: #f3e4c7;
  --note-text: #6b5424;
  
  --disclaimer-bg: #f7f4f9;
  
  --radius-lg: 24px;
  --radius-md: 14px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  --color-scheme: dark;
  
  --purple-primary: #b382d9;
  --purple-dark: #e3d2f5;
  --purple-light: #2c1b3c;
  --purple-glow: rgba(179, 130, 217, 0.25);
  
  --emerald-primary: #4eb88d;
  --emerald-dark: #82e2ba;
  --emerald-light: #162c22;
  
  --gold-accent: #e5bf65;
  --gold-light: #282114;
  
  --bg-gradient: linear-gradient(135deg, #0e0914 0%, #150f1d 100%);
  --card-bg: #1a1324;
  --card-border: #332545;
  --card-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
  --result-bg: linear-gradient(135deg, #261b36 0%, #172a22 100%);
  --result-card-bg: #221930;
  
  --ink-primary: #f3eef8;
  --ink-muted: #a79cb5;
  --line-border: #332545;
  
  --input-bg: #231a30;
  --input-border: #3c2e52;
  --input-border-hover: #835ba6;
  --input-text: #f3eef8;
  --input-placeholder: #6e617d;
  
  --error-color: #ff6b6b;
  --error-bg: rgba(255, 107, 107, 0.12);
  --error-border: rgba(255, 107, 107, 0.35);
  --error-glow: rgba(255, 107, 107, 0.25);
  
  --note-bg: #282114;
  --note-border: #4a3d21;
  --note-text: #ebd79e;
  
  --disclaimer-bg: #20172e;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--bg-gradient);
  color: var(--ink-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

/* SVG Icon Base Styling */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15em;
  height: 1.15em;
  fill: currentColor;
  vertical-align: -0.15em;
  flex-shrink: 0;
}

.icon-stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* Header & Brand with Theme Toggle */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--purple-dark);
  font-size: 13px;
  text-transform: uppercase;
  background: var(--purple-light);
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--line-border);
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--line-border);
  color: var(--ink-primary);
  padding: 8px 16px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  border-color: var(--purple-primary);
  box-shadow: 0 6px 16px var(--purple-glow);
  transform: translateY(-1px);
}

/* Main Card Container */
.hero {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--card-shadow);
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--emerald-light);
  color: var(--emerald-dark);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

h1 {
  font-family: var(--font-heading);
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1.1;
  color: var(--purple-dark);
  margin-bottom: 6px;
  font-weight: 700;
}

.tamil-title {
  font-size: clamp(18px, 3.5vw, 24px);
  font-weight: 700;
  color: var(--emerald-primary);
  margin-bottom: 16px;
}

.intro {
  color: var(--ink-muted);
  font-size: 16px;
  line-height: 1.65;
  max-width: 760px;
}

.section {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--line-border);
}

.section h2 {
  font-family: var(--font-heading);
  font-size: 22px;
  color: var(--purple-dark);
  margin-bottom: 4px;
}

.section p {
  color: var(--ink-muted);
  font-size: 15px;
  margin-bottom: 24px;
}

/* Form Grid & Custom Input Wrappers */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.full {
  grid-column: 1 / -1;
}

.form-group {
  display: flex;
  flex-direction: column;
  position: relative;
}

.form-group.hidden {
  display: none;
}

label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-primary);
  margin-bottom: 8px;
}

label small {
  display: block;
  width: 100%;
  color: var(--ink-muted);
  font-weight: 400;
  font-size: 13px;
  margin-top: 2px;
}

/* Custom Unified Input Wrapper Component */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 54px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  background-color: var(--input-bg);
  padding: 0 16px;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease;
}

.input-wrapper:hover {
  border-color: var(--input-border-hover);
  box-shadow: 0 4px 14px var(--purple-glow);
}

.input-wrapper:focus-within, .input-wrapper.active {
  border-color: var(--purple-primary);
  box-shadow: 0 0 0 4px var(--purple-glow);
}

/* Field Level Error State */
.input-wrapper.has-error {
  border-color: var(--error-color) !important;
  box-shadow: 0 0 0 4px var(--error-glow) !important;
  animation: shake 0.3s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.error-msg {
  display: none;
  align-items: center;
  gap: 6px;
  color: var(--error-color);
  font-size: 13px;
  font-weight: 600;
  margin-top: 6px;
  animation: fadeIn 0.2s ease-out;
}

.error-msg.visible {
  display: flex;
}

/* System Banner Alert */
.banner-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-color);
  font-size: 14px;
  font-weight: 600;
  margin-top: 20px;
  animation: fadeIn 0.3s ease-out;
}

.banner-alert.hidden {
  display: none;
}

.input-prefix-icon {
  color: var(--purple-primary);
  font-size: 18px;
  margin-right: 12px;
  pointer-events: none;
  flex-shrink: 0;
}

.input-wrapper.has-error .input-prefix-icon {
  color: var(--error-color);
}

.input-suffix-icon {
  color: var(--ink-muted);
  font-size: 18px;
  margin-left: 10px;
  pointer-events: none;
  flex-shrink: 0;
  transition: transform 0.2s ease, color 0.2s ease;
}

.input-wrapper:focus-within .input-suffix-icon,
.input-wrapper.active .input-suffix-icon {
  color: var(--purple-primary);
  transform: rotate(180deg);
}

/* Clean Custom Input Elements inside Wrapper */
.input-wrapper input {
  color-scheme: var(--color-scheme);
  flex: 1;
  width: 100%;
  height: 100%;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  color: var(--input-text);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.input-wrapper input::placeholder {
  color: var(--input-placeholder);
  opacity: 1;
}

/* Transparent full-size webkit picker indicator for time input */
#tobGroup .input-wrapper input[type="time"]::-webkit-calendar-picker-indicator {
  display: block !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  opacity: 0 !important;
  cursor: pointer !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Custom Calendar Popover Design */
.calendar-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 1000;
  width: 320px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  padding: 18px;
  display: none;
  animation: fadeIn 0.25s ease-out forwards;
}

.calendar-popover.active {
  display: block;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.calendar-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-border);
  background: var(--card-bg);
  color: var(--ink-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.calendar-nav-btn:hover {
  border-color: var(--purple-primary);
  color: var(--purple-primary);
  background: var(--purple-light);
}

.calendar-selects {
  display: flex;
  align-items: center;
  gap: 6px;
}

.calendar-selects select {
  height: 34px !important;
  min-height: 34px !important;
  padding: 2px 24px 2px 8px !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  border: 1px solid var(--line-border) !important;
  border-radius: var(--radius-sm) !important;
  background-color: var(--card-bg) !important;
  color: var(--ink-primary) !important;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--purple-primary);
  margin-bottom: 8px;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.calendar-day-cell:hover:not(.other-month) {
  background: var(--purple-light);
  color: var(--purple-primary);
}

.calendar-day-cell.other-month {
  color: var(--ink-muted);
  opacity: 0.3;
  cursor: default;
}

.calendar-day-cell.today {
  border: 1.5px solid var(--emerald-primary);
  color: var(--emerald-primary);
}

.calendar-day-cell.selected {
  background: var(--purple-primary) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px var(--purple-glow);
}

.calendar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line-border);
}

.calendar-btn-link {
  background: none;
  border: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--purple-primary);
  cursor: pointer;
  padding: 4px 8px;
}

.calendar-btn-link:hover {
  text-decoration: underline;
}

/* Custom Timezone Dropdown Component */
.tz-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 1000;
  width: 100%;
  max-height: 320px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  padding: 12px;
  display: none;
  flex-direction: column;
  animation: fadeIn 0.25s ease-out forwards;
}

.tz-popover.active {
  display: flex;
}

.tz-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  margin-bottom: 10px;
}

.tz-search-box input {
  border: none !important;
  outline: none !important;
  background: transparent !important;
  font-size: 13px !important;
  color: var(--input-text);
  width: 100%;
}

.tz-options-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: 230px;
  padding-right: 4px;
}

.tz-options-list::-webkit-scrollbar {
  width: 6px;
}

.tz-options-list::-webkit-scrollbar-thumb {
  background: var(--line-border);
  border-radius: 999px;
}

.tz-option-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tz-option-item:hover {
  background: var(--purple-light);
  color: var(--purple-primary);
}

.tz-option-item.selected {
  background: var(--purple-primary);
  color: #ffffff;
  font-weight: 700;
}

/* Action Button */
button.btn-calc {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 28px;
  min-height: 56px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--purple-primary) 0%, var(--emerald-primary) 100%);
  color: #ffffff;
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px var(--purple-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

button.btn-calc:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(92, 53, 119, 0.35);
  filter: brightness(1.06);
}

button.btn-calc:active {
  transform: translateY(0);
}

/* Results Display */
.result {
  display: none;
  margin-top: 32px;
  padding: 32px;
  border: 1px solid var(--line-border);
  border-radius: var(--radius-lg);
  background: var(--result-bg);
  animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--purple-dark);
  margin-bottom: 6px;
}

.devi {
  font-family: var(--font-heading);
  font-size: clamp(32px, 5vw, 46px);
  font-weight: 700;
  color: var(--emerald-primary);
  line-height: 1.1;
  margin-bottom: 4px;
}

.devi-ta {
  font-size: 22px;
  font-weight: 700;
  color: var(--purple-dark);
  margin-bottom: 20px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 20px;
}

.card {
  background: var(--result-card-bg);
  border: 1px solid var(--line-border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.card b {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--purple-primary);
  margin-bottom: 6px;
}

.card span {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-primary);
}

.meaning, .note, .disclaimer {
  margin-top: 20px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.6;
}

.meaning {
  background: var(--result-card-bg);
  border: 1px solid var(--line-border);
}

.note {
  background: var(--note-bg);
  border: 1px solid var(--note-border);
  color: var(--note-text);
}

.disclaimer {
  background: var(--disclaimer-bg);
  border: 1px solid var(--line-border);
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 24px;
}

/* Reference Table Accordion */
details {
  margin-top: 28px;
  border: 1px solid var(--line-border);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  padding: 18px 20px;
}

summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--purple-dark);
  font-weight: 700;
  font-size: 16px;
  user-select: none;
}

summary:hover {
  color: var(--purple-primary);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 14px;
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line-border);
  text-align: left;
  vertical-align: top;
}

th {
  font-family: var(--font-heading);
  color: var(--purple-dark);
  font-weight: 700;
  font-size: 14px;
}

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

/* Sharing & Footer */
.share {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
  text-align: center;
  padding: 20px;
  border-radius: var(--radius-md);
  background: var(--card-bg);
  border: 1px solid var(--line-border);
  font-size: 15px;
}

.footer {
  text-align: center;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.6;
  margin-top: 28px;
}

/* Responsive Rules */
@media (max-width: 720px) {
  .shell {
    padding: 16px 12px 40px;
  }

  .header-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .brand-mark {
    font-size: 11px;
    padding: 6px 14px;
    gap: 6px;
  }

  .theme-toggle-btn {
    padding: 8px;
    width: 38px;
    height: 38px;
    min-width: 38px;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .theme-toggle-btn span {
    display: none;
  }
  
  .hero {
    padding: 22px 14px;
  }
  
  .grid, .cards {
    grid-template-columns: 1fr;
  }
  
  .full {
    grid-column: auto;
  }
  
  .result {
    padding: 20px;
  }
  
  .share {
    flex-direction: column;
    text-align: center;
  }
  
  .calendar-popover {
    width: 100%;
    max-width: 100%;
    left: 0;
    right: 0;
    padding: 14px 10px;
    box-sizing: border-box;
  }

  .calendar-header {
    gap: 4px;
  }

  .calendar-selects {
    gap: 4px;
  }

  .calendar-selects select {
    padding: 2px 16px 2px 6px !important;
    font-size: 12px !important;
  }

  .calendar-days {
    gap: 2px;
  }

  .calendar-day-cell {
    font-size: 12px;
  }
  
  table {
    font-size: 13px;
  }
  
  th, td {
    padding: 8px 6px;
  }
}

