/**
 * BaZi Calculator v9.0 - Styles
 * Refined dark theme with gold accents
 */

:root {
    --bg-primary: #0a0f1a;
    --bg-secondary: #111827;
    --bg-card: #1a2234;
    --bg-card-hover: #1e2a42;
    --gold: #d4af37;
    --gold-light: #f4d03f;
    --gold-dark: #b8960c;
    --text-primary: #f0e6d3;
    --text-secondary: #a0a0a0;
    --text-muted: #6b7280;
    --border-color: #2d3748;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --wood: #22c55e;
    --fire: #ef4444;
    --earth: #eab308;
    --metal: #94a3b8;
    --water: #3b82f6;
    --auspicious: #22c55e;
    --neutral: #eab308;
    --inauspicious: #ef4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Noto Serif SC', serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0d1525 50%, var(--bg-primary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container { max-width: 1100px; margin: 0 auto; padding: 10px; }

/* Header */
.header {
    text-align: center;
    padding: 20px 10px;
    background: linear-gradient(180deg, rgba(212, 175, 55, 0.1) 0%, transparent 100%);
    border-bottom: 1px solid var(--gold-dark);
    margin-bottom: 20px;
}

.header h1 {
    font-family: 'Cinzel', serif;
    font-size: 1.6rem;
    color: var(--gold);
    text-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
}

.header .subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

.header .version {
    font-size: 0.7rem;
    color: var(--gold-dark);
    margin-top: 3px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    color: var(--gold);
}

.card-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.badge-fixed { background: var(--info); color: white; }
.badge-annual { background: var(--warning); color: black; }
.badge-daily { background: var(--success); color: white; }
.badge-hourly { background: #8b5cf6; color: white; }

/* Input Section */
.input-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.form-group { display: flex; flex-direction: column; gap: 4px; }

.form-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.form-group input, .form-group select {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--gold);
}

.btn-calculate {
    grid-column: 1 / -1;
    padding: 14px;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    border: none;
    border-radius: 8px;
    color: var(--bg-primary);
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-calculate:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
}

/* Section Headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.section-title {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    color: var(--gold);
}

/* Results Hidden */
.results-hidden { display: none; }
.results-visible { display: block; }

/* Flying Star Grid */
.flying-star-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    max-width: 280px;
    margin: 0 auto;
}

.fs-cell {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 2px solid var(--border-color);
    position: relative;
    min-height: 70px;
}

.fs-cell.auspicious { border-color: var(--auspicious); background: rgba(34, 197, 94, 0.1); }
.fs-cell.neutral { border-color: var(--neutral); background: rgba(234, 179, 8, 0.1); }
.fs-cell.inauspicious { border-color: var(--inauspicious); background: rgba(239, 68, 68, 0.1); }

.fs-cell .direction {
    font-size: 0.6rem;
    color: var(--text-muted);
    position: absolute;
    top: 2px;
    left: 4px;
}

.fs-cell .star-num {
    font-size: 1.4rem;
    font-weight: 700;
}

.fs-cell .star-name {
    font-size: 0.55rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 2px;
}

.fs-cell.afflicted::after {
    content: '⚠️';
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.7rem;
}

/* Star Legend */
.star-legend {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    font-size: 0.7rem;
    flex-wrap: wrap;
}

.legend-auspicious { color: var(--auspicious); }
.legend-neutral { color: var(--neutral); }
.legend-inauspicious { color: var(--inauspicious); }

/* Pillars */
.pillars-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pillar {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    min-width: 65px;
    text-align: center;
}

.pillar-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.pillar-stem, .pillar-branch {
    padding: 5px;
    border-radius: 4px;
    margin: 3px 0;
}

.pillar-chinese {
    font-size: 1.1rem;
    font-weight: 600;
}

.pillar-pinyin {
    font-size: 0.6rem;
    color: var(--text-secondary);
}

.element-wood { background: rgba(34, 197, 94, 0.2); color: var(--wood); }
.element-fire { background: rgba(239, 68, 68, 0.2); color: var(--fire); }
.element-earth { background: rgba(234, 179, 8, 0.2); color: var(--earth); }
.element-metal { background: rgba(148, 163, 184, 0.2); color: var(--metal); }
.element-water { background: rgba(59, 130, 246, 0.2); color: var(--water); }

/* Day Master Display */
.day-master-display {
    text-align: center;
    margin-top: 10px;
}

.day-master-display .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.day-master-display .value {
    font-weight: 700;
    color: var(--gold);
    font-size: 1rem;
}

/* Info Text */
.info-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.year-display, .date-display {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

/* Eight Mansions Grid */
.mansions-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 10px;
}

.mansion-cell {
    background: var(--bg-secondary);
    border-radius: 6px;
    padding: 8px;
    text-align: center;
}

.mansion-cell.favorable {
    border: 1px solid var(--auspicious);
    background: rgba(34, 197, 94, 0.1);
}

.mansion-cell.unfavorable {
    border: 1px solid var(--inauspicious);
    background: rgba(239, 68, 68, 0.1);
}

.mansion-dir {
    font-weight: 700;
    font-size: 0.9rem;
}

.mansion-name {
    font-size: 0.6rem;
    color: var(--text-secondary);
}

.mansion-chinese {
    font-size: 0.7rem;
    color: var(--gold);
}

/* Affliction List */
.affliction-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.affliction-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-secondary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
}

.affliction-icon { font-size: 1rem; }
.affliction-name { font-weight: 600; }
.affliction-dir { color: var(--text-muted); }

/* Dual Grid */
.dual-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

@media (max-width: 700px) {
    .dual-grid { grid-template-columns: 1fr; }
}

/* Conflict Matrix */
.matrix-container {
    overflow-x: auto;
}

.conflict-matrix {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.conflict-matrix th, .conflict-matrix td {
    padding: 8px 6px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.conflict-matrix th {
    background: var(--bg-secondary);
    color: var(--gold);
    font-weight: 600;
    font-size: 0.7rem;
}

.conflict-matrix td {
    background: var(--bg-card);
}

.conflict-matrix tr:hover td {
    background: var(--bg-card-hover);
}

.score-cell {
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
}

.score-excellent { background: var(--auspicious); color: white; }
.score-good { background: rgba(34, 197, 94, 0.6); color: white; }
.score-caution { background: var(--neutral); color: black; }
.score-avoid { background: var(--inauspicious); color: white; }
.score-blocked { background: #7f1d1d; color: white; }

.rating-chip {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
}

.chip-green { background: rgba(34, 197, 94, 0.2); color: var(--auspicious); }
.chip-yellow { background: rgba(234, 179, 8, 0.2); color: var(--neutral); }
.chip-red { background: rgba(239, 68, 68, 0.2); color: var(--inauspicious); }

/* Recommendation Box */
.recommendation-box {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(212, 175, 55, 0.05));
    border: 2px solid var(--gold);
    border-radius: 12px;
    padding: 20px;
    margin-top: 15px;
}

.recommendation-title {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    color: var(--gold);
    margin-bottom: 10px;
}

.best-direction {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--auspicious);
    margin: 10px 0;
}

.reason-list {
    list-style: none;
    padding: 0;
}

.reason-list li {
    padding: 5px 0;
    padding-left: 20px;
    position: relative;
    font-size: 0.85rem;
}

.reason-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--auspicious);
    font-weight: 700;
}

.reason-list li.warning::before {
    content: '⚠';
    color: var(--warning);
}

/* Alternative Box */
.alternative-box {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
}

.alternative-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.alternative-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-card);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.8rem;
}

.alternative-option .option-label {
    color: var(--gold);
    font-weight: 600;
    min-width: 60px;
}

/* No Direction Warning */
.no-direction-warning {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid var(--danger);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.no-direction-warning h3 {
    color: var(--danger);
    font-family: 'Cinzel', serif;
    margin-bottom: 10px;
}

.no-direction-warning p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Remedies Grid */
.remedies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.remedy-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 10px;
    border-left: 3px solid var(--gold);
}

.remedy-direction {
    font-weight: 600;
    color: var(--gold);
    font-size: 0.8rem;
}

.remedy-star {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.remedy-action {
    font-size: 0.75rem;
    color: var(--text-primary);
    margin-top: 5px;
}

/* Element Analysis */
.element-analysis {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 12px;
    margin-top: 10px;
}

.element-relationship {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin: 10px 0;
}

.element-box {
    padding: 8px 12px;
    border-radius: 6px;
    text-align: center;
}

.element-arrow {
    font-size: 1.5rem;
    color: var(--gold);
}

.relationship-type {
    text-align: center;
    font-weight: 600;
    padding: 5px 15px;
    border-radius: 4px;
    margin-top: 10px;
}

.rel-productive { background: rgba(34, 197, 94, 0.2); color: var(--auspicious); }
.rel-controlling { background: rgba(239, 68, 68, 0.2); color: var(--inauspicious); }
.rel-weakening { background: rgba(234, 179, 8, 0.2); color: var(--neutral); }
.rel-same { background: rgba(59, 130, 246, 0.2); color: var(--info); }

/* Hourly Timeline */
.hourly-timeline {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.hour-cell {
    background: var(--bg-secondary);
    border-radius: 6px;
    padding: 6px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.hour-cell.current {
    border-color: var(--gold);
    background: rgba(212, 175, 55, 0.15);
}

.hour-cell.excellent {
    border-color: var(--auspicious);
    background: rgba(34, 197, 94, 0.1);
}

.hour-cell .hour-time {
    font-size: 0.6rem;
    color: var(--text-muted);
}

.hour-cell .hour-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.hour-cell .hour-star {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-top: 3px;
    display: inline-block;
}

.hour-cell .hour-star.auspicious { background: rgba(34, 197, 94, 0.3); color: var(--auspicious); }
.hour-cell .hour-star.neutral { background: rgba(234, 179, 8, 0.3); color: var(--neutral); }
.hour-cell .hour-star.inauspicious { background: rgba(239, 68, 68, 0.3); color: var(--inauspicious); }

/* Flight Direction */
.flight-direction {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* Best Hours Grid */
.best-hours-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
}

.best-hour-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    border: 2px solid transparent;
}

.best-hour-card.rank-1 {
    border-color: var(--gold);
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(212, 175, 55, 0.05));
}

.best-hour-card.rank-2 { border-color: var(--auspicious); }
.best-hour-card.rank-3 { border-color: var(--info); }

.best-hour-card .hour-rank {
    font-size: 0.65rem;
    color: var(--gold);
    font-weight: 600;
}

.best-hour-card .hour-time-range {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 3px 0;
}

.best-hour-card .hour-chinese {
    font-size: 0.8rem;
    color: var(--gold);
}

.best-hour-card .hour-star-info {
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-top: 3px;
}

/* Why Section */
.why-section {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 12px;
    margin-top: 10px;
}

.why-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.why-title {
    font-size: 0.8rem;
    color: var(--gold);
}

.why-content {
    padding-top: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* Validation Panel */
/* Validation Panel */
.validation-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 15px;
}

.validation-header {
    background: #f8fafc;
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.validation-header:hover {
    background: #f1f5f9;
}

.validation-intro p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.4;
}

.validation-content {
    display: none;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    background: #fff;
    max-height: 400px;
    overflow-y: auto;
}

.validation-content.show {
    display: block;
}

.test-item {
    padding: 10px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.85rem;
}

.test-item:last-child {
    border-bottom: none;
}

.test-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.test-icon {
    font-size: 1rem;
}

.test-error {
    color: #ef4444;
    font-family: monospace;
    margin-top: 4px;
    padding-left: 24px;
    font-size: 0.8rem;
}

/* Famous Test Case Highlight */
.test-famous {
    background-color: #f0fdf4;
    border-left: 3px solid #22c55e;
    margin: 4px 0;
    border-radius: 0 4px 4px 0;
}

.test-famous .test-name {
    font-weight: 600;
    color: #15803d;
}

/* Notifications */
@keyframes slideDown {
    from { transform: translate(-50%, -20px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.notification-toast {
    font-weight: 500;
    text-align: center;
    line-height: 1.4;
    min-width: 300px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.7rem;
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
}

/* Responsive */
@media (max-width: 600px) {
    .mansions-grid { grid-template-columns: repeat(2, 1fr); }
    .hourly-timeline { grid-template-columns: repeat(3, 1fr); }
}
