/* Material Design Icon Imports */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=Roboto+Mono:wght@400;500&display=swap');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');

/* CSS Custom Properties for Material Design System */
:root {
    --md-sys-color-primary: #dc2626;
    --md-sys-color-primary-container: #fee2e2;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-on-primary-container: #7f1d1d;
    --md-sys-color-secondary: #1e40af;
    --md-sys-color-secondary-container: #dbeafe;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-on-secondary-container: #1e3a8a;
    --md-sys-color-surface: #ffffff;
    --md-sys-color-surface-variant: #f1f5f9;
    --md-sys-color-on-surface: #0f172a;
    --md-sys-color-on-surface-variant: #475569;
    --md-sys-color-outline: #cbd5e1;
    --md-sys-color-outline-variant: #e2e8f0;
    --md-sys-color-background: #f8fafc;
    --md-elevation-level1: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
    --md-elevation-level2: 0px 1px 2px 0px rgba(0, 0, 0, 0.3), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
    --md-elevation-level3: 0px 4px 8px 3px rgba(0, 0, 0, 0.15), 0px 1px 3px 0px rgba(0, 0, 0, 0.3);
    --md-elevation-level4: 0px 6px 10px 4px rgba(0, 0, 0, 0.15), 0px 2px 3px 0px rgba(0, 0, 0, 0.3);
}

/* Global Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    background: var(--md-sys-color-background);
    color: var(--md-sys-color-on-surface);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, var(--md-sys-color-primary) 0%, var(--md-sys-color-secondary) 100%);
    color: var(--md-sys-color-on-primary);
    padding: 32px 0;
    margin-bottom: 24px;
    border-radius: 16px;
    box-shadow: var(--md-elevation-level3);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="stars" x="0" y="0" width="20" height="20" patternUnits="userSpaceOnUse"><circle cx="10" cy="10" r="1" fill="%23ffffff" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23stars)"/></svg>');
    animation: float 20s infinite linear;
    pointer-events: none;
}

@keyframes float {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    position: relative;
    z-index: 1;
}

.logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--md-sys-color-surface);
    padding: 8px;
    box-shadow: var(--md-elevation-level2);
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo:hover {
    transform: scale(1.05);
    box-shadow: var(--md-elevation-level3);
}

.logo-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    border-radius: 50%;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo-link:focus {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: 2px;
}

.logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-text {
    text-align: center;
}

.header h1 {
    margin: 0;
    font-size: 2.75rem;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    letter-spacing: -0.025em;
}

.header p {
    margin: 8px 0 0 0;
    font-size: 1.125rem;
    opacity: 0.9;
    font-weight: 400;
}

/* Surface Container */
.surface-container {
    background: var(--md-sys-color-surface);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--md-elevation-level1);
}

.stats-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

/* Search Styles */
.search-container {
    position: relative;
    max-width: 320px;
    min-width: 280px;
}

.search-field {
    width: 100%;
    padding: 16px 16px 16px 48px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: 28px;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.search-field:focus {
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 1px var(--md-sys-color-primary);
}

.search-field:hover:not(:focus) {
    border-color: var(--md-sys-color-on-surface);
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 20px;
}

/* Refresh Controls */
.refresh-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.refresh-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.refresh-btn:hover {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

.refresh-btn:active {
    transform: scale(0.95);
}

/* Table Styles */
.data-table-container {
    background: var(--md-sys-color-surface);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--md-elevation-level1);
    margin-bottom: 24px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th {
    background: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface-variant);
    padding: 16px 20px;
    text-align: left;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    position: sticky;
    top: 0;
    z-index: 10;
}

.sortable-header {
    display: flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: inherit;
    transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sortable-header:hover {
    color: var(--md-sys-color-primary);
}

.sort-icon {
    font-size: 16px;
    opacity: 0.5;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sort-icon.active {
    opacity: 1;
    color: var(--md-sys-color-primary);
}

td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    vertical-align: middle;
}

tr:hover {
    background: var(--md-sys-color-surface-variant);
}

/* File Cell Styles */
.file-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-icon {
    color: var(--md-sys-color-on-surface-variant);
    font-size: 20px;
}

.row-directory .file-icon {
    color: var(--md-sys-color-primary);
}

.row-audio .file-icon {
    color: var(--md-sys-color-secondary);
}

.file-link {
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.file-link:hover {
    color: var(--md-sys-color-primary);
}

.program-name {
    color: var(--md-sys-color-on-surface-variant);
    font-style: italic;
}

.file-size {
    font-family: 'Roboto Mono', monospace;
    color: var(--md-sys-color-on-surface-variant);
}

.file-date {
    font-family: 'Roboto Mono', monospace;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.8125rem;
}

/* Audio Player Styles */
.audio-preview-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.audio-preview-btn:hover {
    background: var(--md-sys-color-secondary);
    color: var(--md-sys-color-on-secondary);
    transform: scale(1.1);
}

.audio-preview-btn.playing {
    background: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
}

/* Global Player Styles */
.global-player {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--md-sys-color-surface);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--md-elevation-level4);
    z-index: 1000;
    min-width: 320px;
    max-width: 400px;
}

.player-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.player-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.track-info {
    flex: 1;
}

.track-name {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--md-sys-color-on-surface-variant);
}

.progress-container {
    flex: 1;
    height: 4px;
    background: var(--md-sys-color-outline-variant);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--md-sys-color-outline-variant);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.progress-fill {
    height: 100%;
    background: var(--md-sys-color-primary);
    border-radius: 2px;
    transition: width 0.1s ease;
    width: 0%;
}

.player-controls {
    display: flex;
    gap: 4px;
}

.player-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.player-btn:hover {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}

/* Footer Styles */
.footer {
    text-align: center;
    padding: 24px 0;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 0.875rem;
}

.footer p {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 16px 8px;
    }

    .header h1 {
        font-size: 2.25rem;
    }

    .header-content {
        flex-direction: column;
        gap: 16px;
    }

    .stats-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-container {
        max-width: none;
        min-width: 0;
    }

    .data-table-container {
        overflow-x: auto;
    }

    table {
        font-size: 0.8125rem;
        min-width: 600px; /* Ensure table doesn't shrink too much */
    }

    th, td {
        padding: 12px 16px;
    }

    .global-player {
        left: 10px;
        right: 10px;
        bottom: 10px;
        min-width: 0;
        max-width: none;
    }

    .player-content {
        flex-direction: column;
        gap: 12px;
    }

    .player-info {
        width: 100%;
    }
}
