@charset "UTF-8";

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--font-color);
    line-height: 1.6;
    padding-top: 40px; /* Space for fixed header */
}

.main-container {
    max-width: 1000px;
    margin: 0 auto 20px auto;
    padding: 0 20px;
}

/* Page Header */
.page-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 0px 10px 20px 10px;
}

.page-header h1 {
    color: var(--font-color);
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.page-header p {
    color: var(--font-color);
    font-size: 1.1rem;
    opacity: 0.8;
    margin: 0;
}

/* Controls Section */
.controls-section {
    background: var(--content-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
    max-width: 300px;
}

.control-group label {
    font-weight: 600;
    color: var(--font-color);
    font-size: 14px;
}

.control-group select {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: var(--alt-content-bg-color);
    color: var(--font-color);
    transition: all 0.3s ease;
    max-width: 100%;
}

.control-group select:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.control-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    justify-content: center;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #45a049;
}

.btn-secondary {
    background: #2196F3;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #1976D2;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #d32f2f;
}

.btn-export {
    background: #FF9800;
    color: white;
}

.btn-export:hover:not(:disabled) {
    background: #F57C00;
}

.icon {
    font-size: 16px;
}

/* Current Reading Section */
.current-reading {
    background: var(--content-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.db-display {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-shrink: 0;
}

.db-value {
    font-size: 2.8rem;
    font-weight: 300;
    color: #4CAF50;
    font-family: 'Courier New', monospace;
    line-height: 1;
}

.db-unit {
    font-size: 1.4rem;
    color: var(--font-color);
    opacity: 0.7;
}

/* Audio Level Bar */
.level-bar-container {
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    margin: 0 15px;
}

.level-bar-wrapper {
    position: relative;
}

.level-bar {
    width: 100%;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    position: relative;
}

.level-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(to right, 
        #4CAF50 0%, 
        #4CAF50 33%, 
        #FF9800 66%, 
        #f44336 100%);
    transition: width 0.1s ease-out;
    border-radius: 8px;
}

.level-markers {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 12px;
    color: var(--font-color);
    font-weight: 600;
}

.marker {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    padding: 2px 4px;
    border-radius: 3px;
    backdrop-filter: blur(5px);
}

.marker.quiet { 
    color: #2E7D32;
}
.marker.moderate { 
    color: #E65100;
}
.marker.loud { 
    color: #C62828;
}
.marker.peak { 
    color: #B71C1C;
}

.status-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
    flex-shrink: 0;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: var(--alt-content-bg-color);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.label {
    font-weight: 600;
    color: var(--font-color);
    min-width: 80px;
}

.status-text {
    color: var(--font-color);
    font-family: 'Courier New', monospace;
    font-weight: 500;
}

/* Graph Section */
.graph-section {
    background: var(--content-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.graph-controls {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--alt-content-bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    align-items: center;
    flex-wrap: wrap;
}

.graph-control-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.graph-control-group label {
    font-weight: 600;
    color: var(--font-color);
    white-space: nowrap;
}

.graph-control-group select {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    background: var(--content-bg-color);
    color: var(--font-color);
    font-size: 14px;
    min-width: 120px;
}

.graph-control-group select:focus {
    outline: none;
    border-color: #4CAF50;
}

.graph-control-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    accent-color: #4CAF50;
}

.canvas-container {
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    background: #ffffff;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden;
    min-height: 400px;
}

#dbCanvas {
    width: 100%;
    height: auto;
    display: block;
    background: #ffffff;
    min-height: 450px;
    max-width: 100%;
}

/* Statistics Section */
.statistics-section {
    background: var(--content-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.statistics-section h3 {
    color: var(--font-color);
    margin-bottom: 20px;
    font-size: 1.3rem;
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--alt-content-bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-label {
    font-weight: 600;
    color: var(--font-color);
    font-size: 14px;
}

.stat-value {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #4CAF50;
    font-size: 16px;
}

/* Export Section */
.export-section {
    background: var(--content-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.export-section h3 {
    color: var(--font-color);
    margin-bottom: 20px;
    font-size: 1.3rem;
    font-weight: 600;
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.export-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    .main-container {
        padding: 0 15px;
        margin: 15px auto;
    }

    .page-header {
        padding: 15px 5px;
        margin-bottom: 20px;
    }

    .page-header h1 {
        font-size: 2rem;
    }

    .page-header p {
        font-size: 1rem;
    }

    .controls-section {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        padding: 15px;
    }

    .control-group {
        min-width: auto;
        max-width: none;
    }

    .control-group select {
        padding: 14px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .control-buttons {
        flex-direction: column;
        gap: 12px;
    }

    .btn {
        min-width: auto;
        padding: 14px 20px;
        font-size: 16px; /* Better touch target */
    }

    /* Current Reading - Stack Vertically */
    .current-reading {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 20px;
        padding: 20px 15px;
    }

    .db-display {
        order: 1;
    }

    .level-bar-container {
        order: 2;
        width: 100%;
        max-width: none;
        margin: 0;
    }

    .status-info {
        order: 3;
        width: 100%;
        min-width: auto;
    }

    .db-value {
        font-size: 2.2rem;
    }

    .db-unit {
        font-size: 1.2rem;
    }

    .level-bar {
        height: 24px; /* Slightly taller for better visibility */
    }

    .level-markers {
        font-size: 11px;
        margin-top: 8px;
    }

    .marker {
        padding: 3px 6px;
        font-size: 11px;
    }

    /* Graph Controls - Stack Vertically */
    .graph-controls {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
        padding: 15px;
    }

    .graph-control-group {
        justify-content: space-between;
        width: 100%;
    }

    .graph-control-group select {
        flex: 1;
        min-width: 150px;
        padding: 12px;
        font-size: 16px;
    }

    .canvas-container {
        padding: 10px;
        min-height: 350px;
    }

    #dbCanvas {
        min-height: 300px;
    }

    /* Statistics Grid - Single Column */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-item {
        padding: 12px 15px;
    }

    .stat-label {
        font-size: 15px;
    }

    .stat-value {
        font-size: 15px;
    }

    /* Export Buttons - Stack Vertically */
    .export-buttons {
        flex-direction: column;
        gap: 12px;
    }

    .export-section,
    .statistics-section,
    .graph-section {
        padding: 15px;
    }
}

/* Small Mobile (480px and below) */
@media (max-width: 480px) {
    .main-container {
        padding: 0 10px;
        margin: 10px auto;
    }

    .page-header {
        padding: 10px 5px;
        margin-bottom: 15px;
    }

    .page-header h1 {
        font-size: 1.8rem;
    }

    .page-header p {
        font-size: 0.9rem;
    }

    .controls-section,
    .current-reading,
    .graph-section,
    .statistics-section,
    .export-section {
        padding: 12px;
        margin-bottom: 15px;
    }

    .db-value {
        font-size: 1.8rem;
    }

    .db-unit {
        font-size: 1rem;
    }

    .btn {
        padding: 12px 16px;
        font-size: 15px;
    }

    .canvas-container {
        padding: 8px;
        min-height: 300px;
    }

    #dbCanvas {
        min-height: 250px;
    }

    .level-bar {
        height: 20px;
    }

    .level-markers {
        font-size: 10px;
        margin-top: 6px;
    }

    .marker {
        padding: 2px 4px;
        font-size: 10px;
    }

    .status-item {
        padding: 8px 10px;
    }

    .label {
        font-size: 13px;
        min-width: 60px;
    }

    .status-text {
        font-size: 13px;
    }

    .stat-item {
        padding: 10px 12px;
    }

    .stat-label,
    .stat-value {
        font-size: 14px;
    }
}

/* Dark mode specific adjustments */
@media (prefers-color-scheme: dark) {
    .canvas-container {
        background: #ffffff;
    }
    
    #dbCanvas {
        background: #ffffff;
    }
    
    .marker.quiet { 
        color: #94c596;
    }
    .marker.moderate { 
        color: #facb85;
    }
    .marker.loud { 
        color: #e09898;
    }
    .marker.peak { 
        color: #f87c73;
    }
}

/* Accessibility improvements */
.btn:focus {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}

select:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

/* Touch-friendly improvements */
@media (max-width: 768px) {
    .btn,
    select,
    input[type="checkbox"] {
        min-height: 44px; /* iOS recommended minimum touch target */
    }
    
    .control-group select {
        min-height: 48px;
    }
    
    .stat-item {
        min-height: 50px;
    }
}

/* Landscape mobile optimization */
@media (max-width: 896px) and (orientation: landscape) {
    .current-reading {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .db-display {
        order: 1;
        flex: 0 0 auto;
    }
    
    .level-bar-container {
        order: 2;
        flex: 1;
        margin: 0 15px;
    }
    
    .status-info {
        order: 3;
        flex: 0 0 auto;
        min-width: 180px;
    }
    
    .canvas-container {
        min-height: 200px;
    }
    
    #dbCanvas {
        min-height: 150px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .stat-item,
    .status-item {
        border-width: 2px;
    }
    
    .marker {
        border: 1px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .btn,
    .stat-item,
    .db-value,
    .stat-value,
    .level-fill {
        transition: none;
    }
    
    .btn:hover,
    .stat-item:hover {
        transform: none;
    }
}

/* Print styles */
@media print {
    .controls-section,
    .export-section {
        display: none;
    }
    
    .main-container {
        max-width: none;
        margin: 0;
        padding: 0;
    }
    
    .canvas-container {
        border: 1px solid #000;
        page-break-inside: avoid;
    }
    
    .page-header h1 {
        color: #000;
    }
    
    .page-header p {
        color: #000;
    }
}