@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

:root {
    --primary-color: #4a90e2;
    --secondary-color: #2ecc71;
    --background-color: #1a252f;
    --surface-color: #2c3e50;
    --surface-light: #34495e;
    --text-color: #ecf0f1;
    --text-secondary-color: #bdc3c7;
    --error-color: #e74c3c;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.2);
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ============== HEADER ============== */

header {
    background: linear-gradient(135deg, var(--surface-color) 0%, var(--surface-light) 100%);
    padding: 1.5em 2em;
    text-align: center;
    box-shadow: var(--shadow);
    border-bottom: 3px solid var(--primary-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

header p {
    margin: 0.3em 0 0;
    font-size: 1rem;
    color: var(--text-secondary-color);
    font-weight: 300;
}

header nav {
    margin-top: 1em;
    display: flex;
    justify-content: center;
    gap: 1em;
    flex-wrap: wrap;
}

header nav a {
    color: white;
    text-decoration: none;
    padding: 0.5em 1.2em;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-weight: 500;
    background-color: rgba(255, 255, 255, 0.1);
}

header nav a:hover {
    background-color: var(--primary-color);
}

header nav a.logout-link {
    background-color: transparent;
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

header nav a.logout-link:hover {
    background-color: rgba(231, 76, 60, 0.15);
    color: #c0392b;
    border-color: #c0392b;
}

/* ============== MAIN LAYOUT ============== */

main {
    max-width: 1400px;
    margin: 2em auto;
    padding: 0 1.5em;
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2em;
}

main.admin-main {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
    gap: 2em;
}

section {
    background-color: var(--surface-color);
    padding: 1.5em 2em;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow);
}

h2 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5em;
    margin-top: 0;
    margin-bottom: 1.5em;
    font-weight: 600;
    font-size: 1.4rem;
}

h3 {
    color: var(--text-color);
    font-weight: 500;
    margin-top: 1.5em;
    margin-bottom: 1em;
}

/* ============== DASHBOARD GRID ============== */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1em;
    margin-bottom: 1.5em;
}

.stat-card {
    background: linear-gradient(135deg, var(--surface-light) 0%, #3b5068 100%);
    padding: 1.2em;
    border-radius: var(--border-radius);
    text-align: center;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-card h3 {
    color: var(--text-secondary-color);
    margin: 0 0 0.5em 0;
    font-size: 0.9em;
    font-weight: 400;
}

.stat-card p {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--secondary-color);
    margin: 0;
}

/* ============== ADMIN DASHBOARD ============== */

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1em;
    margin-bottom: 1.5em;
}

.admin-stat-card {
    background: linear-gradient(135deg, var(--surface-light) 0%, #3b5068 100%);
    padding: 1.2em;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 1em;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.admin-stat-card .stat-icon {
    font-size: 2em;
    opacity: 0.9;
}

.admin-stat-card .stat-info {
    display: flex;
    flex-direction: column;
}

.admin-stat-card .stat-value {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--secondary-color);
}

.admin-stat-card .stat-label {
    font-size: 0.85em;
    color: var(--text-secondary-color);
}

.admin-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1em;
    background-color: var(--surface-light);
    border-radius: var(--border-radius);
    margin-top: 1em;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5em;
    font-weight: 600;
    padding: 0.3em 0.8em;
    border-radius: 20px;
}

.status-indicator.active {
    color: var(--success-color);
    border: 1px solid var(--success-color);
    background-color: transparent;
}

.status-indicator.inactive {
    color: var(--error-color);
    border: 1px solid var(--error-color);
    background-color: transparent;
}

.last-update {
    font-size: 0.85em;
    color: var(--text-secondary-color);
}

/* ============== STATIONS LIST ============== */

.stations-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5em;
}

.stations-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8em 1em;
    border-radius: var(--border-radius);
    background-color: var(--surface-light);
    transition: var(--transition);
}

.stations-list li:hover {
    background-color: #4a6a8a;
}

.stations-list .station-name {
    font-weight: 500;
    flex: 1;
}

.station-status {
    font-weight: 500;
    padding: 0.3em 0.8em;
    border-radius: 20px;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 0.4em;
}

.status-running {
    background-color: transparent;
    color: var(--success-color);
    border: 1px solid var(--success-color);
    font-weight: 600;
}

.status-stopped {
    background-color: transparent;
    color: var(--error-color);
    border: 1px solid var(--error-color);
    font-weight: 500;
}

/* ============== ADMIN STATION LIST ============== */

#station-list-admin ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5em;
}

#station-list-admin li {
    background-color: var(--surface-light);
    padding: 1em 1.2em;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

#station-list-admin li:hover {
    background-color: #4a6a8a;
}

#station-list-admin .station-name {
    font-weight: 500;
    flex: 1;
}

#station-list-admin .station-actions {
    display: flex;
    align-items: center;
    gap: 1em;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #4a6a8a;
    border-radius: 24px;
    transition: var(--transition);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--success-color);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Status Badges */
.status-badge {
    padding: 0.3em 0.8em;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 500;
}

.status-enabled {
    background-color: rgba(46, 204, 113, 0.2);
    color: var(--success-color);
}

.status-disabled {
    background-color: transparent;
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

.status-recording {
    background-color: transparent;
    color: var(--success-color);
    border: 1px solid var(--success-color);
    font-weight: 600;
    animation: pulse 2s infinite;
}

.status-warning {
    background-color: rgba(243, 156, 18, 0.2);
    color: var(--warning-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ============== RECORDINGS ============== */

.recordings-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5em;
    gap: 1em;
    flex-wrap: wrap;
}

#search-recordings,
#admin-search-recordings {
    flex: 1;
    min-width: 200px;
    padding: 0.8em 1em;
    border: 1px solid #4a6a8a;
    background-color: var(--surface-light);
    color: var(--text-color);
    border-radius: var(--border-radius);
    font-size: 1em;
    transition: var(--transition);
}

#search-recordings:focus,
#admin-search-recordings:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

#recordings-container,
#admin-recordings-container {
    display: flex;
    flex-direction: column;
    gap: 1em;
}

.station-recordings {
    background-color: var(--surface-light);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.station-recordings h3 {
    background: linear-gradient(135deg, var(--primary-color) 0%, #5a9ee2 100%);
    color: white;
    margin: 0;
    padding: 0.8em 1.2em;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1em;
    font-weight: 500;
    transition: var(--transition);
}

.station-recordings h3:hover {
    background: linear-gradient(135deg, #5a9ee2 0%, #6aade2 100%);
}

.station-recordings h3 .toggle-icon {
    font-size: 0.9em;
    transition: transform 0.3s ease;
}

.station-recordings h3.expanded .toggle-icon {
    transform: rotate(90deg);
}

.station-recordings h3 .recording-count {
    font-weight: 400;
    font-size: 0.9em;
    opacity: 0.9;
    margin-left: 0.5em;
}

.recordings-table-wrapper {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out;
}

.recordings-table-wrapper.expanded {
    max-height: none;
    padding: 1em;
}

/* ============== TABLE STYLES ============== */

.recordings-list table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.recordings-list th,
.recordings-list td {
    text-align: left;
    padding: 0.7em 0.8em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recordings-list th {
    background-color: #3b5068;
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
    white-space: nowrap;
    font-size: 0.9em;
}

.recordings-list tbody tr {
    transition: background-color 0.2s ease;
}

.recordings-list tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Column sizing - optimized widths */
.col-checkbox { width: 40px; text-align: center; }
.col-id { display: none !important; } /* Hidden globally - ID not needed */
.col-date { width: 140px; }
.col-duration { width: 80px; text-align: center; }
.col-size { width: 80px; text-align: center; }
.col-player { width: auto; min-width: 200px; }
.col-download, .col-actions { width: 120px; text-align: center; }

/* Ensure action column content is centered */
.col-download, .col-actions {
    padding-left: 0.5em !important;
    padding-right: 0.5em !important;
}

td.col-download, td.col-actions {
    text-align: center !important;
}

/* Admin table specific - ensure consistent columns */
.admin-recordings table,
#admin-recordings-container table {
    table-layout: auto;
    width: 100%;
}

.admin-recordings th,
.admin-recordings td,
#admin-recordings-container th,
#admin-recordings-container td {
    padding: 0.6em 0.5em;
    vertical-align: middle;
}

.admin-recordings .col-checkbox,
#admin-recordings-container .col-checkbox {
    width: 40px;
    text-align: center;
}

.admin-recordings .col-date,
#admin-recordings-container .col-date {
    width: 140px;
}

.admin-recordings .col-duration,
#admin-recordings-container .col-duration {
    width: 70px;
    text-align: center;
}

.admin-recordings .col-size,
#admin-recordings-container .col-size {
    width: 70px;
    text-align: center;
}

.admin-recordings .col-player,
#admin-recordings-container .col-player {
    width: 220px;
    max-width: 220px;
}

.admin-recordings .col-player audio,
#admin-recordings-container .col-player audio {
    width: 100%;
    max-width: 200px;
}

.admin-recordings .col-actions,
#admin-recordings-container .col-actions {
    width: 100px;
    text-align: center;
}

/* Center button inside actions column */
#admin-recordings-container td.col-actions,
.admin-recordings td.col-actions {
    text-align: center !important;
}

#admin-recordings-container td.col-actions button,
.admin-recordings td.col-actions button {
    margin: 0 auto;
}

/* Audio player styling */
.recordings-list audio {
    width: 100%;
    max-width: 220px;
    height: 32px;
    border-radius: var(--border-radius);
}

/* Download button - GREEN text on neutral background */
.recordings-list .download-btn,
.recordings-list a.download-btn,
.station-recordings .download-btn,
td.col-download .download-btn,
td.col-actions .download-btn {
    display: inline-block;
    background-color: transparent !important;
    color: var(--success-color) !important;
    padding: 0.45em 0.9em;
    border: 1px solid var(--success-color) !important;
    border-radius: var(--border-radius);
    cursor: pointer;
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 600;
    transition: var(--transition);
    white-space: nowrap;
}

.recordings-list .download-btn:hover,
.recordings-list a.download-btn:hover,
.station-recordings .download-btn:hover,
td.col-download .download-btn:hover,
td.col-actions .download-btn:hover {
    background-color: rgba(46, 204, 113, 0.15) !important;
    color: #27ae60 !important;
    border-color: #27ae60 !important;
    transform: translateY(-1px);
}

/* All action buttons in tables should be styled */
.recordings-list td .action-button,
.station-recordings td .action-button {
    padding: 0.4em 0.8em;
    font-size: 0.8em;
}

/* ============== BUTTONS ============== */

.action-button {
    color: white;
    padding: 0.7em 1.5em;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
}

.action-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.action-button.cleanup-button {
    background-color: transparent;
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

.action-button.cleanup-button:hover:not(:disabled) {
    background-color: rgba(231, 76, 60, 0.15);
    color: #c0392b;
    border-color: #c0392b;
}

.action-button.success-button {
    background-color: transparent;
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.action-button.success-button:hover:not(:disabled) {
    background-color: rgba(46, 204, 113, 0.15);
    color: #27ae60;
    border-color: #27ae60;
}

.action-button.primary-button {
    background-color: var(--primary-color);
}

.action-button.primary-button:hover:not(:disabled) {
    background-color: #5a9ee2;
}

.action-button.start-button {
    background-color: transparent;
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.action-button.start-button:hover:not(:disabled) {
    background-color: rgba(46, 204, 113, 0.15);
    color: #27ae60;
    border-color: #27ae60;
}

.action-button.stop-button {
    background-color: transparent;
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

.action-button.stop-button:hover:not(:disabled) {
    background-color: rgba(231, 76, 60, 0.15);
    color: #c0392b;
    border-color: #c0392b;
}

.action-button.small-button {
    padding: 0.4em 0.8em;
    font-size: 0.85em;
}

.action-button.delete-button {
    background-color: transparent;
    color: var(--error-color);
    border: 1px solid var(--error-color);
}

.action-button.delete-button:hover:not(:disabled) {
    background-color: rgba(231, 76, 60, 0.15);
    color: #c0392b;
    border-color: #c0392b;
}

.action-button.disabled-button {
    background-color: #4a6a8a;
    cursor: not-allowed;
}

/* Batch download button - GREEN text */
.batch-download-btn {
    background-color: transparent;
    color: var(--success-color);
    padding: 0.6em 1.2em;
    border: 1px solid var(--success-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    transition: var(--transition);
    margin: 1em;
    display: inline-block;
}

.batch-download-btn:hover:not(:disabled) {
    background-color: rgba(46, 204, 113, 0.15);
    color: #27ae60;
    border-color: #27ae60;
}

.batch-download-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============== PAGINATION ============== */

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1em;
    padding: 1em;
}

.pagination-controls button {
    background-color: var(--primary-color);
    color: white;
    padding: 0.5em 1em;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.pagination-controls button:hover:not(:disabled) {
    background-color: #5a9ee2;
}

.pagination-controls button:disabled {
    background-color: #4a6a8a;
    cursor: not-allowed;
    opacity: 0.6;
}

.pagination-controls span {
    color: var(--text-secondary-color);
    font-size: 0.95em;
}

/* ============== FORMS ============== */

.add-station-section {
    margin-top: 2em;
    padding-top: 1.5em;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#add-station-form {
    display: flex;
    flex-direction: column;
    gap: 1em;
}

.form-row {
    display: flex;
    gap: 1em;
}

.form-row input {
    flex: 1;
}

#add-station-form input[type="text"],
#add-station-form input[type="url"] {
    padding: 0.8em 1em;
    border: 1px solid #4a6a8a;
    border-radius: var(--border-radius);
    background-color: var(--surface-light);
    color: var(--text-color);
    font-size: 1em;
    transition: var(--transition);
}

#add-station-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

#add-station-form button {
    align-self: flex-start;
}

#config-form {
    display: flex;
    flex-direction: column;
    gap: 1em;
}

.config-item {
    display: flex;
    align-items: center;
    gap: 1em;
    flex-wrap: wrap;
}

.config-item label {
    color: var(--text-secondary-color);
    font-size: 1em;
}

#config-form input[type="number"] {
    padding: 0.6em 1em;
    border: 1px solid #4a6a8a;
    border-radius: var(--border-radius);
    background-color: var(--surface-light);
    color: var(--text-color);
    font-size: 1em;
    width: 100px;
    transition: var(--transition);
}

#config-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

#config-form button {
    align-self: flex-start;
}

/* ============== NOTIFICATIONS ============== */

.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 1em 1.5em;
    border-radius: var(--border-radius);
    color: white;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 350px;
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    background-color: var(--success-color);
}

.notification-error {
    background-color: var(--error-color);
}

.notification-warning {
    background-color: var(--warning-color);
}

.notification-info {
    background-color: var(--primary-color);
}

/* ============== NO RECORDINGS MESSAGE ============== */

.no-recordings {
    text-align: center;
    padding: 2em;
    color: var(--text-secondary-color);
    font-style: italic;
}

/* ============== FOOTER ============== */

footer {
    text-align: center;
    padding: 1em 0;
    color: var(--text-secondary-color);
    font-size: 0.9em;
    background-color: var(--surface-color);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
}

/* Add padding to body to prevent content from being hidden behind fixed footer */
body {
    padding-bottom: 60px;
}

/* ============== CHECKBOXES ============== */

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--success-color);
}

/* ============== RECORDING PROGRESS BAR ============== */

.recording-progress {
    width: 100%;
    padding: 0.5em 0 0.2em;
    display: flex;
    flex-direction: column;
    gap: 0.3em;
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 3px;
    transition: width 1s linear;
    min-width: 0;
}

.progress-bar-fill.waiting {
    background: repeating-linear-gradient(
        90deg,
        var(--primary-color) 0%,
        var(--secondary-color) 50%,
        var(--primary-color) 100%
    );
    background-size: 200% 100%;
    animation: waiting-pulse 2s ease-in-out infinite;
    opacity: 0.5;
}

@keyframes waiting-pulse {
    0% { background-position: 0% 0; }
    100% { background-position: 200% 0; }
}

.progress-text {
    font-size: 0.75em;
    color: var(--text-secondary-color);
    text-align: right;
}

#station-list-admin .recording-progress {
    padding: 0.4em 0 0;
}

/* ============== RECORDING STATUS ============== */

.recording-in-progress {
    background-color: rgba(74, 144, 226, 0.08);
}

.status-badge-recording {
    display: inline-block;
    background: linear-gradient(135deg, var(--error-color), #c0392b);
    color: #fff;
    font-size: 0.7em;
    padding: 0.15em 0.5em;
    border-radius: 4px;
    font-weight: 500;
    animation: recording-blink 1.5s ease-in-out infinite;
    vertical-align: middle;
    margin-left: 0.4em;
}

@keyframes recording-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.recording-size {
    color: var(--warning-color);
    font-style: italic;
    font-size: 0.9em;
}

.recording-placeholder {
    color: var(--text-secondary-color);
    font-style: italic;
    font-size: 0.85em;
}

/* ============== RESPONSIVE DESIGN ============== */

@media (max-width: 1200px) {
    main {
        grid-template-columns: 300px 1fr;
        gap: 1.5em;
    }
}

@media (max-width: 900px) {
    header h1 {
        font-size: 1.6rem;
    }

    main {
        grid-template-columns: 1fr;
        padding: 0 1em;
    }

    .sidebar {
        order: 2;
    }

    .main-content {
        order: 1;
    }

    section {
        padding: 1.2em;
    }

    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }

    .admin-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .recordings-controls {
        flex-direction: column;
        align-items: stretch;
    }

    #search-recordings,
    #admin-search-recordings {
        width: 100%;
    }
}

@media (max-width: 768px) {
    header {
        padding: 1em;
    }

    header h1 {
        font-size: 1.4rem;
    }

    header nav {
        gap: 0.5em;
    }

    header nav a {
        padding: 0.4em 0.8em;
        font-size: 0.9em;
    }

    .recordings-list table {
        table-layout: auto;
    }

    .recordings-list th,
    .recordings-list td {
        padding: 0.5em 0.4em;
        font-size: 0.85em;
    }

    .col-checkbox { width: 35px; }
    .col-id { width: 40px; }
    .col-date { width: auto; min-width: 100px; }
    .col-duration { width: 55px; }
    .col-size { width: 60px; }
    .col-player { width: auto; min-width: 120px; }
    .col-download, .col-actions { width: 90px; }

    .recordings-list audio {
        max-width: 120px;
        height: 30px;
    }

    .recordings-list .download-btn {
        padding: 0.35em 0.5em;
        font-size: 0.75em;
    }

    .recordings-list .action-button.delete-button {
        padding: 0.3em 0.5em;
        font-size: 0.75em;
    }

    .admin-stats-grid {
        grid-template-columns: 1fr;
    }

    .admin-stat-card {
        padding: 1em;
    }

    .form-row {
        flex-direction: column;
    }

    #station-list-admin li {
        flex-direction: column;
        gap: 0.8em;
        align-items: flex-start;
    }

    #station-list-admin .station-actions {
        width: 100%;
        justify-content: space-between;
    }

    .action-button {
        padding: 0.5em 1em;
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    main {
        padding: 0 0.5em;
        margin: 1em auto;
        margin-bottom: 70px;
    }

    section {
        padding: 0.8em;
        border-radius: var(--border-radius);
    }

    h2 {
        font-size: 1.1rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .stat-card p {
        font-size: 1.4em;
    }

    .station-recordings h3 {
        font-size: 0.95em;
        padding: 0.6em 0.8em;
    }

    .recordings-list th,
    .recordings-list td {
        padding: 0.4em 0.25em;
        font-size: 0.8em;
    }

    /* Hide less important columns on mobile */
    .col-duration,
    .col-size {
        display: none;
    }

    /* ID is always hidden */
    .col-id {
        display: none !important;
    }

    .col-date { min-width: 90px; }
    .col-player { min-width: 100px; }
    .col-download, .col-actions { width: 75px; }

    .recordings-list audio {
        max-width: 100px;
        height: 28px;
    }

    .recordings-list .download-btn {
        padding: 0.3em 0.4em;
        font-size: 0.7em;
    }

    .recordings-list .action-button.delete-button {
        padding: 0.25em 0.4em;
        font-size: 0.7em;
    }

    .pagination-controls {
        flex-wrap: wrap;
        gap: 0.5em;
    }

    .pagination-controls button {
        padding: 0.4em 0.7em;
        font-size: 0.85em;
    }

    .notification {
        left: 10px;
        right: 10px;
        bottom: 70px;
        max-width: none;
    }

    .batch-download-btn {
        font-size: 0.8em;
        padding: 0.5em 0.8em;
        margin: 0.5em;
    }
}

/* ============== ANTI-FLICKER & PERFORMANCE ============== */

/* Prevent layout shifts during updates */
#recordings-container,
#admin-recordings-container,
#stations-list,
#station-list-admin {
    min-height: 100px;
    contain: layout style;
}

.station-recordings {
    contain: layout style;
    will-change: auto;
}

/* Smooth tbody updates without flicker */
.recordings-list tbody {
    transition: opacity 0.15s ease-out;
}

/* Fade in new content smoothly */
.recordings-list tbody tr {
    animation: rowFadeIn 0.2s ease-out;
}

@keyframes rowFadeIn {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

/* Station list smooth updates */
.stations-list ul,
#station-list-admin ul {
    contain: layout style;
}

.stations-list li,
#station-list-admin li {
    animation: itemFadeIn 0.15s ease-out;
}

@keyframes itemFadeIn {
    from { opacity: 0.8; }
    to { opacity: 1; }
}

/* Admin dashboard smooth updates */
.admin-stats-grid {
    contain: layout style;
}

.admin-stat-card .stat-value {
    transition: opacity 0.15s ease-out;
}

/* ============== ANIMATIONS ============== */

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

.station-recordings {
    animation: fadeIn 0.2s ease-out;
}

/* Smooth row transitions */
.recordings-list tbody tr {
    transition: background-color 0.2s ease, opacity 0.15s ease;
}

/* ============== SCROLLBAR STYLING ============== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface-color);
}

::-webkit-scrollbar-thumb {
    background: #4a6a8a;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5a7a9a;
}

/* ============== STATION CONTROLS ============== */

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

.station-controls {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.station-controls button {
    flex: 1;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-start {
    background-color: #2ecc71;
    color: white;
}

.btn-start:hover:not(:disabled) {
    background-color: #27ae60;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.3);
}

.btn-stop {
    background-color: #e74c3c;
    color: white;
}

.btn-stop:hover:not(:disabled) {
    background-color: #c0392b;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

.station-controls button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.hidden {
    display: none !important;
}

/* ============== NOTIFICATIONS ============== */

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 500;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-success {
    background-color: #2ecc71;
}

.notification-error {
    background-color: #e74c3c;
}

.notification-warning {
    background-color: #f39c12;
}

.notification-info {
    background-color: #3498db;
}

/* ============== RADIO & TV SECTIONS ============== */

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5em;
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.75em 0;
    padding-bottom: 0.5em;
    border-bottom: 2px solid var(--surface-light);
}

.radio-title {
    border-bottom-color: var(--primary-color);
}

.tv-title {
    border-bottom-color: #e74c3c;
}

.section-icon {
    font-size: 1.1em;
}

.active-count {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 500;
    background: var(--secondary-color);
    color: #fff;
    padding: 0.15em 0.6em;
    border-radius: 999px;
}

.active-count:empty {
    display: none;
}

.sources-list {
    margin-bottom: 1.5em;
}

.sources-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.source-quality {
    font-size: 0.68rem;
    color: var(--text-secondary-color);
    background: var(--surface-light);
    padding: 0.1em 0.5em;
    border-radius: 4px;
    margin-left: 0.5em;
}

/* ============== VIDEO PLAYER ============== */

video.recording-player {
    width: 100%;
    max-width: 320px;
    height: auto;
    border-radius: var(--border-radius);
    background: #000;
    display: block;
}

.media-type-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15em 0.5em;
    border-radius: 4px;
    margin-right: 0.3em;
    text-transform: uppercase;
}

.media-type-badge.audio {
    background: var(--primary-color);
    color: #fff;
}

.media-type-badge.video {
    background: #e74c3c;
    color: #fff;
}

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

@media print {
    header nav,
    .action-button,
    .batch-download-btn,
    .pagination-controls,
    .station-controls,
    audio {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    section {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
