/* ZWDS Calculator Styles */

.zwds-calculator-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Calculator Form */
.calculator-form {
    background: #ffffff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
}

.calculator-form h2 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 28px;
    border-bottom: 3px solid #667eea;
    padding-bottom: 15px;
    margin-bottom: 25px;
}

#quota-display {
    text-align: right;
    color: #666;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 15px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

#upgrade-notice {
    display: none;
    background: linear-gradient(135deg, #fff3cd 0%, #ffe5a1 100%);
    border: 2px solid #ffc107;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    text-align: center;
}

#upgrade-notice strong {
    display: block;
    font-size: 18px;
    color: #856404;
    margin-bottom: 10px;
}

#upgrade-notice p {
    color: #666;
    margin: 10px 0;
}

.btn-upgrade {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    padding: 12px 30px;
    border: none;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.2s;
    cursor: pointer;
}

.btn-upgrade:hover {
    transform: translateY(-2px);
}

/* Form Elements */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

#zwds-calculate-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 40px;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 20px;
}

#zwds-calculate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

#zwds-calculate-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Loading Spinner */
#loading-spinner {
    display: none;
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Messages */
#error-message {
    display: none;
    margin: 20px 0;
}

.error-box {
    background: #f8d7da;
    border: 2px solid #f5c6cb;
    color: #721c24;
    padding: 15px;
    border-radius: 6px;
}

/* Results Section */
#calculate-results {
    display: none;
}

.results-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: 12px 12px 0 0;
    margin-top: 30px;
}

.results-header h3 {
    margin: 0 0 10px 0;
    font-size: 24px;
}

#lunar-date-display,
#ming-palace-info {
    font-size: 16px;
    opacity: 0.95;
    margin: 5px 0;
}

/* Chart Container */
#chart-container {
    position: relative;
    background: white;
    padding: 30px;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* Chart Grid Layout - Standard */
.zwds-chart-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 0; /* Remove gap for cleaner borders */
    background: #000; /* Black border lines */
    border: 2px solid #000;
    overflow: hidden; /* Keep overlapping content inside */
    margin: 20px 0;
    aspect-ratio: 4/3.25; /* Use aspect ratio from spec (800x650) */
    position: relative; /* For Overlay positioning */
}

/* Central Area (Spans 2x2) */
.zwds-center {
    grid-column: 2 / 4;
    grid-row: 2 / 4;
    background: #fff;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 5; /* Above overlays */
}

/* Palace Styling */
.palace-cell {
    background: #ffffff;
    padding: 8px; /* Reduced padding for density */
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    outline: 1px solid #000; /* Distinct borders */
    z-index: 2;
}

.palace-cell:hover:not(.zwds-center) {
    background: #f0f7ff;
    z-index: 10;
}

.palace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
    padding-bottom: 4px;
    margin-bottom: 6px;
}

.palace-name {
    font-weight: 700;
    font-size: 1.1em;
    color: #c0392b; /* Traditional red */
}

.palace-branch {
    font-weight: 600;
    font-size: 1.1em;
    color: #2c3e50;
}

.palace-stars {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    flex-grow: 1;
    align-content: flex-start;
}

/* =========================================
   STYLE VARIATIONS
   ========================================= */

/* 1. Flying Star Style (飞星) */
.style-feixing .palace-name { color: #8e44ad; }
.style-feixing .star.minor { display: none; } /* Hide minor stars */

/* 2. Three Harmony Style (三合) - Detailed, All Stars */
.style-sanhe .palace-cell { font-size: 0.9em; }
.style-sanhe .star { margin: 1px; }

/* 3. Four Transformations Style (四化) - Minimal */
.style-sihua .palace-stars { justify-content: center; margin-top: 10px; }
.style-sihua .star.major { font-size: 1.1em; }
.style-sihua .star.hua {
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}
.style-sihua .star.minor, 
.style-sihua .star.assistant,
.style-sihua .star.sha { display: none; } /* Strictly minimal */


/* =========================================
   SVG OVERLAY SYSTEM
   ========================================= */
.zwds-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through */
    z-index: 4; /* Below center, above palaces */
}

/* Style specific overlay visibility */
.style-feixing .overlay-feixing { display: block; }
.style-feixing .overlay-sihua { display: none; }

.style-sihua .overlay-sihua { display: block; }
.style-sihua .overlay-feixing { display: none; }

.style-sanhe .zwds-overlay { display: none; } /* No overlay for Sanhe */

/* Transformation legends in chart center */
.feixing-legend, .sihua-legend {
    margin-top: 8px;
    font-size: 11px;
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}
.feixing-legend { color: #666; }
.leg-lu, .leg-a { color: #27ae60; font-weight: bold; }
.leg-quan, .leg-b { color: #e74c3c; font-weight: bold; }
.leg-ke, .leg-c { color: #8e44ad; font-weight: bold; }
.leg-ji, .leg-d { color: #2c3e50; font-weight: bold; }

/* =========================================
   STYLE SWITCHER UI
   ========================================= */
.style-switcher {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
}

.btn-style {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    color: #555;
}

.btn-style:hover { background: #eee; }

.btn-style.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
    box-shadow: 0 2px 5px rgba(102, 126, 234, 0.4);
}

/* Four Transformations */
.transformations-info {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.transformations-info h4 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 18px;
    margin-bottom: 15px;
}

.transformations-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.transformation {
    padding: 15px;
    border-radius: 6px;
    text-align: center;
}

.transformation.lu {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
    color: white;
}

.transformation.quan {
    background: linear-gradient(135deg, #f85032 0%, #e73827 100%);
    color: white;
}

.transformation.ke {
    background: linear-gradient(135deg, #4776e6 0%, #8e54e9 100%);
    color: white;
}

.transformation.ji {
    background: linear-gradient(135deg, #434343 0%, #000000 100%);
    color: white;
}

.transformation .type {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 5px;
    opacity: 0.9;
}

.transformation .star {
    display: block;
    font-size: 16px;
    font-weight: 700;
    background: none;
    padding: 0;
}

/* Pricing Table */
.zwds-pricing-table {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    margin: 40px 0;
}

.pricing-card {
    background: white;
    border-radius: 12px;
    padding: 40px 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    text-align: center;
    position: relative;
    transition: transform 0.3s;
}

.pricing-card:hover {
    transform: translateY(-5px);
}

.pricing-card.premium {
    border: 3px solid #667eea;
}

.pricing-card .badge {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 20px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.pricing-card h3 {
    margin-top: 0;
    font-size: 24px;
    color: #2c3e50;
}

.pricing-card .price {
    font-size: 48px;
    font-weight: 700;
    color: #667eea;
    margin: 20px 0;
}

.pricing-card .price span {
    font-size: 18px;
    color: #999;
}

.pricing-card .features {
    list-style: none;
    padding: 0;
    margin: 30px 0;
    text-align: left;
}

.pricing-card .features li {
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
    color: #666;
}

.pricing-card .btn-select {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.pricing-card.free .btn-select {
    background: #e0e0e0;
    color: #999;
}

.pricing-card.premium .btn-select {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.pricing-card.premium .btn-select:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Responsive Design */
@media (max-width: 768px) {
    .calculator-form {
        padding: 25px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .zwds-chart-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(8, 1fr);
    }
    
    .palace-cell {
        min-height: 110px;
        padding: 10px;
    }
    
    .palace-name {
        font-size: 14px;
    }
    
    .palace-branch {
        font-size: 11px;
    }
    
    .star {
        font-size: 10px;
        padding: 3px 6px;
    }
    
    .transformations-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .zwds-pricing-table {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .calculator-form {
        padding: 20px;
    }

    .palace-cell {
        min-height: 90px;
        padding: 8px;
    }

    .results-header {
        padding: 20px 15px;
    }

    #chart-container {
        padding: 15px;
    }
}

/* ========================================
   AI INTERPRETATION SECTION
   ======================================== */

.ai-interpretation {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-top: 30px;
    overflow: hidden;
}

.ai-interpretation h4 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin: 0;
    padding: 20px 25px;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#ai-content {
    padding: 25px;
    line-height: 1.8;
    color: #444;
}

#ai-content p {
    margin: 0 0 15px 0;
}

#ai-content p:last-child {
    margin-bottom: 0;
}

.ai-teaser {
    text-align: center;
    padding: 40px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    margin-top: 30px;
    border: 2px dashed #dee2e6;
}

.ai-teaser h4 {
    margin-top: 0;
    color: #2c3e50;
    font-size: 20px;
}

.ai-teaser p {
    color: #666;
    margin: 10px 0 20px;
}

/* ========================================
   PALACE DETAIL MODAL
   ======================================== */

.palace-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.palace-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.palace-modal {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.palace-modal-overlay.active .palace-modal {
    transform: scale(1);
}

.palace-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.palace-modal-header h3 {
    margin: 0;
    font-size: 22px;
}

.palace-modal-header .branch {
    font-size: 16px;
    opacity: 0.9;
}

.palace-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.palace-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.palace-modal-content {
    padding: 25px;
}

.palace-modal-section {
    margin-bottom: 20px;
}

.palace-modal-section:last-child {
    margin-bottom: 0;
}

.palace-modal-section h4 {
    color: #2c3e50;
    margin: 0 0 12px 0;
    font-size: 16px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.palace-modal-stars {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.palace-modal-description {
    color: #666;
    line-height: 1.7;
    font-size: 14px;
}

/* ========================================
   SUCCESS & INFO MESSAGES
   ======================================== */

.success-box {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 2px solid #28a745;
    color: #155724;
    padding: 15px 20px;
    border-radius: 8px;
    margin: 15px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.success-box::before {
    content: "✓";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #28a745;
    color: white;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
}

.info-box {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    border: 2px solid #17a2b8;
    color: #0c5460;
    padding: 15px 20px;
    border-radius: 8px;
    margin: 15px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.info-box::before {
    content: "i";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #17a2b8;
    color: white;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    font-style: italic;
}

.warning-box {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe5a1 100%);
    border: 2px solid #ffc107;
    color: #856404;
    padding: 15px 20px;
    border-radius: 8px;
    margin: 15px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.warning-box::before {
    content: "!";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #ffc107;
    color: #856404;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
}

/* ========================================
   STAR CATEGORIES & COLORS
   ======================================== */

.star {
    display: inline-block;
    padding: 2px 4px;
    background: none;
    color: #2563eb;  /* Blue for good stars */
    font-size: 0.95em;
    font-weight: 600;
}

/* Good/auspicious stars - blue */
.star.major,
.star.minor,
.star.assistant,
.star.hua {
    color: #2563eb;
}

/* Bad/sha stars - red */
.star.sha {
    color: #dc2626;
}

/* ========================================
   PALACE HIGHLIGHT STATES
   ======================================== */

.palace-cell.ming-palace {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border: 2px solid #667eea;
}

.palace-cell.ming-palace .palace-name {
    color: #667eea;
}

.palace-cell.selected {
    box-shadow: inset 0 0 0 3px #667eea;
}

/* ========================================
   ANIMATIONS & TRANSITIONS
   ======================================== */

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

.slide-in {
    animation: slideIn 0.4s ease forwards;
}

.palace-cell {
    animation: fadeIn 0.3s ease forwards;
}

.palace-cell:nth-child(1) { animation-delay: 0.02s; }
.palace-cell:nth-child(2) { animation-delay: 0.04s; }
.palace-cell:nth-child(3) { animation-delay: 0.06s; }
.palace-cell:nth-child(4) { animation-delay: 0.08s; }
.palace-cell:nth-child(5) { animation-delay: 0.10s; }
.palace-cell:nth-child(6) { animation-delay: 0.12s; }
.palace-cell:nth-child(7) { animation-delay: 0.14s; }
.palace-cell:nth-child(8) { animation-delay: 0.16s; }
.palace-cell:nth-child(9) { animation-delay: 0.18s; }
.palace-cell:nth-child(10) { animation-delay: 0.20s; }
.palace-cell:nth-child(11) { animation-delay: 0.22s; }
.palace-cell:nth-child(12) { animation-delay: 0.24s; }
.palace-cell:nth-child(13) { animation-delay: 0.26s; }
.palace-cell:nth-child(14) { animation-delay: 0.28s; }
.palace-cell:nth-child(15) { animation-delay: 0.30s; }
.palace-cell:nth-child(16) { animation-delay: 0.32s; }

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    /* Page setup for proper sizing */
    @page {
        size: A4 landscape;
        margin: 10mm;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    body {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .zwds-calculator-wrapper {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .calculator-form {
        display: none !important;
    }

    #loading-spinner {
        display: none !important;
    }

    .btn-upgrade,
    #upgrade-notice,
    .ai-teaser,
    .print-hide,
    button {
        display: none !important;
    }

    #calculate-results {
        display: block !important;
        width: 100% !important;
    }

    .results-header {
        background: #667eea !important;
        border-radius: 8px 8px 0 0 !important;
        margin-top: 0 !important;
    }

    #chart-container {
        width: 100% !important;
        padding: 15px !important;
        box-shadow: none !important;
    }

    /* Critical: Fix the chart grid for print */
    .zwds-chart-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        grid-template-rows: repeat(4, auto) !important;
        gap: 1px !important;
        width: 100% !important;
        max-width: 100% !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        overflow: visible !important;
        border: 2px solid #2c3e50 !important;
        box-sizing: border-box !important;
    }

    .palace-cell {
        border: 1px solid #333 !important;
        min-height: 80px !important;
        max-height: none !important;
        padding: 6px !important;
        background: white !important;
        overflow: visible !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        box-sizing: border-box !important;
    }

    .palace-cell:hover {
        transform: none !important;
        box-shadow: none !important;
    }

    .palace-cell.empty {
        background: #f5f5f5 !important;
    }

    .palace-header {
        border-bottom: 1px solid #667eea !important;
        padding-bottom: 4px !important;
        margin-bottom: 6px !important;
    }

    .palace-name {
        font-size: 12px !important;
        font-weight: bold !important;
    }

    .palace-branch {
        font-size: 10px !important;
    }

    .palace-stars {
        gap: 3px !important;
    }

    .star {
        background: none !important;
        color: #2563eb !important;
        font-size: 9px !important;
        padding: 2px 4px !important;
        font-weight: 600 !important;
    }

    .star.sha {
        color: #dc2626 !important;
    }

    /* Four Transformations section */
    .transformations-info {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        margin-top: 15px !important;
        padding: 15px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .transformations-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px !important;
        width: 100% !important;
    }

    .transformation {
        padding: 10px !important;
    }

    .transformation.lu {
        background: #56ab2f !important;
    }

    .transformation.quan {
        background: #e73827 !important;
    }

    .transformation.ke {
        background: #4776e6 !important;
    }

    .transformation.ji {
        background: #333 !important;
    }

    /* AI section - hide for print */
    .ai-interpretation,
    .ai-teaser {
        display: none !important;
    }

    /* Remove animations for print */
    .palace-cell,
    .star {
        animation: none !important;
        transition: none !important;
    }

    /* Ensure no overflow issues */
    .results-header,
    #chart-container,
    .zwds-chart-grid,
    .transformations-info {
        overflow: visible !important;
    }
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */

@media (prefers-color-scheme: dark) {
    .zwds-calculator-wrapper {
        color: #e0e0e0;
    }

    .calculator-form {
        background: #1e1e1e;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }

    .calculator-form h2 {
        color: #f0f0f0;
    }

    #quota-display {
        background: #2d2d2d;
        color: #b0b0b0;
    }

    .form-group label {
        color: #e0e0e0;
    }

    .form-group input,
    .form-group select {
        background: #2d2d2d;
        border-color: #444;
        color: #e0e0e0;
    }

    .form-group input:focus,
    .form-group select:focus {
        border-color: #667eea;
    }

    #chart-container {
        background: #1e1e1e;
    }

    .palace-cell {
        background: #2d2d2d;
    }

    .palace-cell:hover:not(.empty) {
        background: #3d3d3d;
    }

    .palace-cell.empty {
        background: linear-gradient(135deg, #252525 0%, #1a1a1a 100%);
    }

    .palace-name {
        color: #e57373;
    }

    .palace-branch {
        color: #b0b0b0;
    }

    .transformations-info {
        background: #2d2d2d;
    }

    .transformations-info h4 {
        color: #f0f0f0;
    }

    .pricing-card {
        background: #1e1e1e;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }

    .pricing-card h3 {
        color: #f0f0f0;
    }

    .pricing-card .features li {
        color: #b0b0b0;
        border-bottom-color: #333;
    }

    .pricing-card.free .btn-select {
        background: #333;
        color: #888;
    }

    .error-box {
        background: #3d1c1c;
        border-color: #c0392b;
        color: #e57373;
    }

    .success-box {
        background: #1c3d1c;
        border-color: #27ae60;
        color: #81c784;
    }

    .info-box {
        background: #1c2d3d;
        border-color: #2980b9;
        color: #64b5f6;
    }

    .warning-box {
        background: #3d3d1c;
        border-color: #f39c12;
        color: #ffd54f;
    }

    .ai-interpretation {
        background: #1e1e1e;
    }

    #ai-content {
        color: #c0c0c0;
    }

    .ai-teaser {
        background: linear-gradient(135deg, #2d2d2d 0%, #1e1e1e 100%);
        border-color: #444;
    }

    .ai-teaser h4 {
        color: #f0f0f0;
    }

    .ai-teaser p {
        color: #b0b0b0;
    }

    .palace-modal {
        background: #1e1e1e;
    }

    .palace-modal-content {
        color: #e0e0e0;
    }

    .palace-modal-section h4 {
        color: #f0f0f0;
    }

    .palace-modal-description {
        color: #b0b0b0;
    }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

/* Focus states for keyboard navigation */
.form-group input:focus-visible,
.form-group select:focus-visible,
#zwds-calculate-btn:focus-visible,
.btn-upgrade:focus-visible,
.palace-cell:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .spinner {
        animation: none;
        border: 4px solid #667eea;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .star {
        border: 2px solid white;
    }

    .palace-cell {
        border: 2px solid #000;
    }

    .form-group input,
    .form-group select {
        border-width: 3px;
    }
}

/* ========================================
   TOOLTIP STYLES
   ======================================== */

.star-tooltip {
    position: relative;
    cursor: help;
}

.star-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 100;
    pointer-events: none;
}

.star-tooltip::before {
    content: "";
    position: absolute;
    bottom: calc(100% - 5px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 100;
}

.star-tooltip:hover::after,
.star-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mt-30 { margin-top: 30px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.mb-30 { margin-bottom: 30px; }

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gap-10 { gap: 10px; }
.gap-20 { gap: 20px; }

/* Star Visibility Filters */
.hide-minor .star.minor { display: none !important; }
.hide-aux .star.assistant { display: none !important; }
.hide-sha .star.sha { display: none !important; }

.chart-options-controls { text-align: center; margin-bottom: 15px; }
.chart-options-controls label { margin: 0 10px; cursor: pointer; font-size: 0.9em; }
