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

:root {
    /* Updated color palette based on logo colors */
    --primary-gradient: linear-gradient(135deg, #c4b28d 0%, #a89878 50%, #c4b28d 100%);
    --secondary-gradient: linear-gradient(135deg, #d7332a 0%, #b82922 100%);
    --accent-gradient: linear-gradient(135deg, #d7332a 0%, #c4b28d 100%);
    --success-gradient: linear-gradient(135deg, #00b09b 0%, #96c93d 100%);
    --warning-gradient: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
    --error-gradient: linear-gradient(135deg, #d7332a 0%, #b82922 100%);
    
    /* Logo colors */
    --logo-brown: #c4b28d;
    --logo-red: #d7332a;
    
    /* Zone colors */
    --red-zone-gradient: linear-gradient(90deg, #ff416c 0%, #ff4b2b 100%);
    --orange-zone-gradient: linear-gradient(90deg, #f6d365 0%, #fda085 100%);
    --yellow-zone-gradient: linear-gradient(90deg, #ffe259 0%, #ffa751 100%);
    --green-zone-gradient: linear-gradient(90deg, #00b09b 0%, #96c93d 100%);
    
    /* Advanced glass effects */
    --glass-bg: rgba(15, 14, 71, 0.25);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.05);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    
    /* Neumorphic effects */
    --neumorph-bg: #192339;
    --neumorph-light: rgba(255, 255, 255, 0.05);
    --neumorph-shadow: rgba(0, 0, 0, 0.5);
    
    /* Text colors */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --text-tertiary: rgba(255, 255, 255, 0.6);
    --text-accent: #00c6ff;
    
    /* Surface colors */
    --surface-1: rgba(25, 35, 57, 0.7);
    --surface-2: rgba(25, 35, 57, 0.85);
    --surface-3: rgba(25, 35, 57, 0.95);
    
    /* Border radii */
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 24px;
    --border-radius-circle: 50%;
    
    /* Spacing */
    --spacing-xs: 8px;
    --spacing-sm: 16px;
    --spacing-md: 24px;
    --spacing-lg: 32px;
    --spacing-xl: 48px;
    --spacing-2xl: 64px;
    
    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-medium: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.25);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.3);
    
    /* Glow effects */
    --glow-primary: 0 0 20px rgba(110, 72, 170, 0.5);
    --glow-accent: 0 0 20px rgba(0, 198, 255, 0.5);
    --glow-success: 0 0 20px rgba(0, 176, 155, 0.5);
    --glow-red: 0 0 20px rgba(255, 65, 108, 0.5);
    --glow-orange: 0 0 20px rgba(246, 211, 101, 0.5);
    --glow-yellow: 0 0 20px rgba(255, 226, 89, 0.5);
    --glow-green: 0 0 20px rgba(0, 176, 155, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #000000;
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
    font-weight: 400;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 3D particle system */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.15), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.1), transparent),
        radial-gradient(3px 3px at 90px 40px, rgba(255, 255, 255, 0.12), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255, 255, 255, 0.08), transparent),
        radial-gradient(2px 2px at 160px 120px, rgba(255, 255, 255, 0.1), transparent);
    background-repeat: repeat;
    background-size: 200px 200px;
    animation: particleFloat 30s linear infinite;
    z-index: -1;
    perspective: 1000px;
    transform-style: preserve-3d;
}

@keyframes particleFloat {
    0% { transform: translateY(0) translateZ(0) translateX(0); }
    100% { transform: translateY(-100px) translateZ(50px) translateX(50px); }
}

/* Layout with sidebar */
body {
    display: flex;
    overflow-x: hidden;
}

/* Sidebar styles */
.sidebar {
    width: 200px;
    height: 100vh;
    background-color: #121212;
    color: var(--text-primary);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    overflow-y: auto;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
}

.sidebar-header {
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header .logo {
    width: 100px;
    height: auto; /* Maintain aspect ratio */
    max-height: 100px;
    object-fit: contain; /* Ensure the image fits properly */
    margin-bottom: var(--spacing-xs);
}

.sidebar-header h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 16px;
    margin: 0;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
}

.sidebar-section {
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-section h4 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin: var(--spacing-xs) var(--spacing-md);
    font-weight: 600;
    letter-spacing: 1px;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu li {
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    position: relative;
}

.sidebar-menu li:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-menu li.active {
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-menu li.active::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 3px;
    height: 100%;
    background: var(--secondary-gradient);
}

.sidebar-icon {
    margin-right: var(--spacing-sm);
    opacity: 0.8;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-menu li.active .sidebar-icon {
    opacity: 1;
}

/* Font Awesome icons */
.sidebar-icon i {
    font-size: 18px;
}

/* SVG icons */
.sidebar-icon img {
    filter: brightness(0) invert(1); /* Make SVG icons white */
    opacity: 0.8;
    transition: opacity var(--transition-fast);
}

.sidebar-menu li.active .sidebar-icon img {
    opacity: 1;
}

.sidebar-menu li span {
    font-size: 14px;
    font-weight: 500;
}

/* Main container */
#tuner {
    position: relative;
    z-index: 1;
    max-width: 800px; /* Wider container for the linear grid */
    width: 90%;
    margin: var(--spacing-md);
    margin-left: 200px; /* Match sidebar width */
    padding: var(--spacing-lg) 0;
    text-align: center;
    overflow: hidden;
    transform-style: preserve-3d;
    perspective: 1000px;
    flex: 1;
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 200;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 0;
    width: 48px;
    height: 48px;
    cursor: pointer;
    padding: 12px;
    color: var(--text-primary);
    transition: all var(--transition-medium);
}

.mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Mobile sidebar toggle */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-medium);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    #tuner {
        margin-left: var(--spacing-md);
    }
    
    body {
        padding-top: 60px;
    }
}

/* App header with 3D effect */
.app-header {
    margin-bottom: var(--spacing-md);
    position: relative;
    transform-style: preserve-3d;
    perspective: 1000px;
}

h1.app-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 36px;
    font-weight: 800;
    margin-bottom: var(--spacing-xs);
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    line-height: 1.2;
    text-shadow: 0 2px 10px rgba(196, 178, 141, 0.5);
    transform: translateZ(20px);
    animation: titleFloat 6s ease-in-out infinite;
    margin: 0; /* Reset default h1 margin */
}

@keyframes titleFloat {
    0%, 100% { transform: translateZ(20px); }
    50% { transform: translateZ(30px); }
}

h2.app-subtitle {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: 0.9;
    transform: translateZ(10px);
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    margin: 0; /* Reset default h2 margin */
}

/* Advanced status indicator */
.status-indicator {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 14px;
    height: 14px;
    background: var(--success-gradient);
    border-radius: var(--border-radius-circle);
    border: 2px solid rgba(255, 255, 255, 0.2);
    animation: statusPulse 2s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(0, 176, 155, 0.5);
    transform: translateZ(15px);
}

@keyframes statusPulse {
    0%, 100% { 
        transform: translateZ(15px) scale(1);
        box-shadow: 0 0 10px rgba(0, 176, 155, 0.5);
    }
    50% { 
        transform: translateZ(15px) scale(1.2);
        box-shadow: 0 0 20px rgba(0, 176, 155, 0.7);
    }
}

/* Note display container with fixed height */
.note-display-container {
    margin-bottom: var(--spacing-md);
    position: relative;
    perspective: 1000px;
    height: 80px; /* Fixed height to prevent layout shifts */
    display: flex;
    align-items: center;
    justify-content: center;
}

.note-display {
    font-family: 'Orbitron', sans-serif;
    font-size: 64px;
    font-weight: 700;
    color: var(--text-primary);
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    transform: translateZ(15px);
    transition: all var(--transition-medium);
    animation: noteDisplayPulse 2s ease-in-out infinite alternate;
    line-height: 1; /* Prevent line height from affecting container size */
}

/* Make "Ready to tune" and "Listening..." smaller than actual notes */
.note-display:not(.note-detected) {
    font-size: 32px;
    opacity: 0.8;
}

@keyframes noteDisplayPulse {
    from {
        text-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    }
    to {
        text-shadow: 0 8px 16px rgba(196, 178, 141, 0.6);
    }
}

/* 3D neumorphic button */
.buttons-container {
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    position: relative;
    perspective: 1000px;
    display: flex;
    justify-content: center;
}

.buttons-container button {
    position: relative;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.7);
    padding: 16px 36px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 0; /* Square button */
    cursor: pointer;
    transition: all var(--transition-medium);
    font-family: 'Montserrat', sans-serif;
    letter-spacing: 0.05em;
    min-width: 180px;
    overflow: hidden;
    transform: translateY(0) translateZ(10px);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.button-icon {
    margin-right: 5px;
    vertical-align: middle;
}

.buttons-container button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.9);
}

.buttons-container button:active {
    transform: translateY(0) translateZ(5px);
    background: rgba(255, 255, 255, 0.2);
    transition: transform 0.1s, background 0.1s;
}

.buttons-container button.listening {
    background: rgba(0, 0, 0, 0.5);
    border-color: rgba(0, 198, 255, 0.7);
    animation: buttonListening 2s ease-in-out infinite;
}

@keyframes buttonListening {
    0%, 100% { 
        border-color: rgba(0, 198, 255, 0.7);
    }
    50% { 
        border-color: rgba(0, 198, 255, 1);
    }
}

/* Linear Grid Visualizer */
.tuner-grid-container {
    position: relative;
    width: 100%;
    margin: 0 auto var(--spacing-lg);
    perspective: 1000px;
    transform-style: preserve-3d;
}

/* Grid labels */
.grid-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--spacing-xs);
    padding: 0;
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
    width: 100%;
}

.grid-labels span {
    position: relative;
    transform: translateZ(5px);
    flex: 1;
    text-align: center;
}

.grid-labels .target-label {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 14px;
}

/* Main tuning grid */
.tuning-grid {
    position: relative;
    width: 100%;
    height: 60px;
    background: var(--surface-1);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.3),
        0 5px 15px rgba(0, 0, 0, 0.2);
    transform: translateZ(10px);
}

/* Grid cells */
.grid-cells {
    display: flex;
    width: 100%;
    height: 100%;
}

.grid-cell {
    flex: 1;
    height: 100%;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    transition: all var(--transition-medium);
    position: relative;
    overflow: hidden;
}

.grid-cell:last-child {
    border-right: none;
}

.grid-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.1), transparent);
    opacity: 0;
    transition: opacity var(--transition-medium);
}

.grid-cell.active::before {
    opacity: 1;
}

/* Zone styling - simplified color scheme */
.red-zone {
    background-color: rgb(250 68 18 / 30%); /* Updated red with opacity */
}

.red-zone.active {
    background: var(--red-zone-gradient);
    box-shadow: inset 0 0 15px rgba(255, 65, 108, 0.5);
    opacity: 1;
}

.orange-zone {
    background-color: rgba(32, 32, 31, 0.7); /* Dark with opacity */
}

.orange-zone.active {
    background: var(--orange-zone-gradient);
    box-shadow: inset 0 0 15px rgba(246, 211, 101, 0.5);
    opacity: 1;
}

.yellow-zone {
    background-color: rgba(32, 32, 31, 0.7); /* Dark with opacity */
}

.yellow-zone.active {
    background: var(--yellow-zone-gradient);
    box-shadow: inset 0 0 15px rgba(255, 226, 89, 0.5);
    opacity: 1;
}

.green-zone {
    background-color: rgba(32, 32, 31, 0.7); /* Dark with opacity */
}

.green-zone.active {
    background: var(--green-zone-gradient);
    box-shadow: inset 0 0 15px rgba(0, 176, 155, 0.5);
    opacity: 1;
}

/* Tuning cursor */
.tuning-cursor {
    position: absolute;
    top: 0;
    left: 50%; /* Start in the middle */
    width: 10px;
    height: 100%;
    transform: translateX(-50%);
    z-index: 10;
    transition: left var(--transition-medium) cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.cursor-pointer {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 40px;
    background: #ffffff;
    border-radius: 4px;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
    z-index: 2;
}

.cursor-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.8;
    z-index: 1;
    animation: cursorGlowPulse 1.5s ease-in-out infinite alternate;
}

@keyframes cursorGlowPulse {
    from { 
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(1);
    }
    to { 
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1.3);
    }
}

.cursor-trail {
    position: absolute;
    top: 0;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translateX(-50%);
    opacity: 0.3;
    background: linear-gradient(to right, 
        transparent 0%, 
        rgba(255,255,255,0) 40%, 
        rgba(255,255,255,0.8) 50%, 
        rgba(255,255,255,0) 60%, 
        transparent 100%
    );
    z-index: 0;
}

/* Perfect tune animation */
.tuning-cursor.perfect {
    animation: perfectTunePulse 1s ease-in-out infinite alternate;
}

@keyframes perfectTunePulse {
    from { 
        filter: drop-shadow(0 0 10px rgba(0, 176, 155, 0.8));
    }
    to { 
        filter: drop-shadow(0 0 20px rgba(0, 176, 155, 1));
    }
}

/* Frequency and cents displays */
.tuner-info-displays {
    margin-top: var(--spacing-sm);
    display: flex;
    justify-content: center;
    gap: 20px;
    font-family: 'Orbitron', sans-serif;
    transform: translateZ(5px);
}

.frequency-display, .cents-display {
    font-size: 18px;
    color: var(--text-secondary);
}

/* Cents display styling */
.cents-display {
    font-weight: 600;
}

.perfect-cents {
    color: #72ac51; /* Green for perfect tune */
}

.close-cents {
    color: #f6d365; /* Yellow/orange for close */
}

.far-cents {
    color: #d7332a; /* Red for far off */
}

/* Microphone visualization */
.mic-container {
    display: flex;
    justify-content: center;
    margin: var(--spacing-md) 0;
}

.mic-button {
    width: 80px;
    height: 80px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default; /* Remove pointer cursor */
    transition: all var(--transition-medium);
    transform: translateZ(10px);
}

.mic-icon {
    width: 50px; /* Larger icon */
    height: 50px; /* Larger icon */
    color: white;
    transition: all var(--transition-medium);
}

.mic-button.listening {
    animation: micListening 2s ease-in-out infinite;
}

@keyframes micListening {
    0%, 100% { 
        opacity: 0.8;
    }
    50% { 
        opacity: 1;
    }
}

/* Advanced status display with fixed height */
.status {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    height: 60px; /* Fixed height to prevent layout shifts */
    letter-spacing: 0.05em;
    transition: all var(--transition-medium);
    padding: var(--spacing-sm);
    border-radius: 0; /* Square corners */
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.7);
    transform: translateZ(5px);
    margin-top: var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Perfect tune animation */
.status.perfect {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.7);
    color: var(--text-primary);
    animation: perfectTune 2s ease-in-out infinite alternate;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    letter-spacing: 1px;
}

@keyframes perfectTune {
    from { 
        transform: translateZ(5px) scale(1);
        border-color: rgba(255, 255, 255, 0.7);
    }
    to { 
        transform: translateZ(10px) scale(1.03);
        border-color: rgba(255, 255, 255, 0.9);
    }
}

/* Loading state with 3D effect */
.loading {
    opacity: 0.8;
    animation: loadingPulse 1.5s ease-in-out infinite;
    transform: translateZ(5px);
}

@keyframes loadingPulse {
    0%, 100% { 
        opacity: 0.8;
        transform: translateZ(5px);
    }
    50% { 
        opacity: 1;
        transform: translateZ(10px);
    }
}

/* Responsive design with 3D preservation */
@media (max-width: 768px) {
    #tuner {
        max-width: 600px;
    }
}

@media (max-width: 480px) {
    #tuner {
        padding: var(--spacing-lg) var(--spacing-md);
        margin: var(--spacing-sm);
        max-width: none;
        width: calc(100% - 32px);
    }
    
    .app-title {
        font-size: 32px;
    }
    
    .note-display {
        font-size: 48px;
    }
    
    .note-display:not(.note-detected) {
        font-size: 24px;
    }
    
    .buttons-container button {
        padding: 16px 32px;
        font-size: 15px;
    }
    
    .grid-labels {
        font-size: 10px;
    }
    
    .grid-labels .target-label {
        font-size: 12px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transform-style: flat !important;
        transform: none !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --glass-bg: rgba(0, 0, 0, 0.9);
        --glass-border: rgba(255, 255, 255, 0.4);
        --text-secondary: rgba(255, 255, 255, 0.95);
        --text-tertiary: rgba(255, 255, 255, 0.9);
    }
}

/* Focus styles for accessibility */
button:focus-visible {
    outline: 3px solid rgba(0, 198, 255, 0.8);
    outline-offset: 3px;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--surface-1);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 5px;
    border: 2px solid var(--surface-1);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
