/* Pinyin Chart Styles */

/* Table styling */
.pinyin-chart-table {
    font-size: 0.85rem;
    table-layout: fixed;
}

.pinyin-chart-table th,
.pinyin-chart-table td {
    text-align: center;
    vertical-align: middle;
    padding: 0.35rem 0.25rem;
    white-space: nowrap;
}

/* Header cells */
.pinyin-header-cell {
    background-color: #f8f9fa;
    font-weight: 600;
    font-size: 0.8rem;
    min-width: 40px;
}

/* First header cell (Initial/Final label) needs more width */
.pinyin-header-cell:first-child {
    min-width: 100px;
    width: 100px;
    font-size: 0.7rem;
    white-space: normal;
    line-height: 1.2;
}

.pinyin-initial-cell {
    background-color: #e9ecef;
    font-weight: 600;
    min-width: 35px;
    width: 35px;
}

/* Syllable cells */
.pinyin-cell {
    cursor: pointer;
    transition: all 0.15s ease;
    background-color: #fff;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.pinyin-cell:hover:not(.invalid):not(.disabled) {
    background-color: #0d6efd;
    color: #fff;
    transform: scale(1.05);
    z-index: 10;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.pinyin-cell.invalid {
    background-color: #f8f9fa;
    color: #ccc;
    cursor: default;
}

.pinyin-cell.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pinyin-cell.no-tone {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Highlighting */
.pinyin-cell.highlight-initial {
    background-color: #fff3cd;
}

.pinyin-cell.highlight-final {
    background-color: #cfe2ff;
}

.pinyin-cell.highlight-initial.highlight-final {
    background-color: #d1e7dd;
}

/* Tone badges */
.tone-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-weight: bold;
    font-size: 0.75rem;
    margin-right: 0.25rem;
}

.tone-badge.tone-1 {
    background-color: #198754;
    color: #fff;
}

.tone-badge.tone-2 {
    background-color: #0d6efd;
    color: #fff;
}

.tone-badge.tone-3 {
    background-color: #ffc107;
    color: #000;
}

.tone-badge.tone-4 {
    background-color: #dc3545;
    color: #fff;
}

.tone-badge.tone-5 {
    background-color: #6c757d;
    color: #fff;
}

/* Tone colors in cells */
.pinyin-cell[data-tone="1"] {
    color: #198754;
}

.pinyin-cell[data-tone="2"] {
    color: #0d6efd;
}

.pinyin-cell[data-tone="3"] {
    color: #b8860b;
}

.pinyin-cell[data-tone="4"] {
    color: #dc3545;
}

/* Audio status indicator */
#audioStatus {
    z-index: 1050;
    font-size: 0.875rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .pinyin-chart-table {
        font-size: 0.75rem;
    }

    .pinyin-chart-table th,
    .pinyin-chart-table td {
        padding: 0.25rem 0.15rem;
    }

    .pinyin-header-cell,
    .pinyin-initial-cell {
        font-size: 0.7rem;
        min-width: 30px;
    }

    .tone-badge {
        width: 20px;
        height: 20px;
        font-size: 0.65rem;
    }
}

@media (max-width: 576px) {
    .pinyin-chart-table {
        font-size: 0.65rem;
    }

    .pinyin-chart-table th,
    .pinyin-chart-table td {
        padding: 0.2rem 0.1rem;
    }
}

/* Print styles */
@media print {
    .pinyin-cell:hover {
        background-color: #fff;
        color: inherit;
        transform: none;
        box-shadow: none;
    }

    #audioStatus,
    .ad-placeholder,
    .adsbygoogle {
        display: none !important;
    }
}

/* Animation for playing state */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(13, 110, 253, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(13, 110, 253, 0);
    }
}

.pinyin-cell.playing {
    animation: pulse 1s ease-out;
    background-color: #0d6efd;
    color: #fff;
}

/* Scrollable table container */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Card styling consistency */
.card-header {
    font-weight: 600;
    background-color: #f8f9fa;
}

/* Pronunciation tips list */
.card-body ul {
    padding-left: 1.25rem;
}

.card-body ul li {
    margin-bottom: 0.25rem;
}

/* Button group for tones */
.btn-group-tones .btn {
    min-width: 80px;
}

/* Sticky header for large tables */
.pinyin-chart-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Reference table (more compact) */
.pinyin-reference-table {
    font-size: 0.8rem;
}

.pinyin-reference-table th,
.pinyin-reference-table td {
    padding: 0.25rem 0.2rem;
}

/* Enhanced print styles for reference page */
@media print {
    /* Hide non-essential elements */
    .no-print,
    nav,
    footer,
    .sidebar,
    .btn-print,
    .tone-selector-card,
    #audioStatus,
    .ad-placeholder,
    .adsbygoogle {
        display: none !important;
    }

    /* Full width layout */
    .container,
    .container-fluid {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .row {
        margin: 0 !important;
    }

    .col-lg-9,
    .col-lg-12 {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        padding: 0 5px !important;
    }

    /* Typography adjustments */
    body {
        font-size: 10pt !important;
        line-height: 1.3 !important;
    }

    h1 {
        font-size: 14pt !important;
        margin-bottom: 8px !important;
    }

    /* Table print optimization */
    .pinyin-chart-table,
    .pinyin-reference-table {
        font-size: 8pt !important;
        page-break-inside: avoid;
    }

    .pinyin-chart-table th,
    .pinyin-chart-table td,
    .pinyin-reference-table th,
    .pinyin-reference-table td {
        padding: 2px 3px !important;
        border: 1px solid #333 !important;
    }

    .pinyin-header-cell,
    .pinyin-initial-cell {
        background-color: #e0e0e0 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .pinyin-cell {
        cursor: default !important;
    }

    .pinyin-cell:hover {
        background-color: transparent !important;
        color: inherit !important;
        transform: none !important;
        box-shadow: none !important;
    }

    .pinyin-cell.invalid {
        color: #999 !important;
    }

    .pinyin-cell.disabled,
    .pinyin-cell.no-tone {
        opacity: 0.4 !important;
    }

    /* Card print styles */
    .card {
        border: 1px solid #333 !important;
        margin-bottom: 8px !important;
        page-break-inside: avoid;
    }

    .card-header {
        background-color: #f0f0f0 !important;
        padding: 4px 8px !important;
        font-size: 9pt !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .card-body {
        padding: 6px 8px !important;
    }

    /* Show print-only elements */
    .d-print-inline {
        display: inline !important;
    }

    .d-print-block {
        display: block !important;
    }

    /* Page break control */
    .page-break-before {
        page-break-before: always;
    }

    .page-break-after {
        page-break-after: always;
    }
}



/* Legend styling */
.tone-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.tone-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Focus styles for accessibility */
.pinyin-cell:focus {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
}

/* Loading state */
.pinyin-chart-loading {
    opacity: 0.5;
    pointer-events: none;
}

.pinyin-chart-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}


@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Neutral Tone Section Styles */
.neutral-tone-btn {
    font-size: 0.85rem;
    padding: 0.35rem 0.65rem;
    transition: all 0.15s ease;
    background-color: #e9ecef;
    border-color: #6c757d;
    color: #495057;
}

.neutral-tone-btn:hover {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #fff;
}

.neutral-tone-btn:hover .text-primary {
    color: #fff !important;
}

.neutral-tone-btn:hover .text-muted {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Tone 5 (Neutral) button in tone selector */
.tone-btn.tone-5,
.btn.tone-5 {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #fff;
}

.tone-btn.tone-5:hover,
.btn.tone-5:hover {
    background-color: #5a6268;
    border-color: #545b62;
    color: #fff;
}

/* Example words table */
.table-hover tbody tr:hover {
    cursor: pointer;
}

.table-hover tbody tr:hover td {
    background-color: rgba(13, 110, 253, 0.1);
}

/* Neutral tone highlight color */
.neutral-tone-btn .text-primary,
table .text-primary {
    color: #6c757d !important;
    font-weight: 600;
}
