/* 
   Clean Mobile Styles - Matching Desktop Aesthetics
   Preserving the elegant look and feel on smaller screens
*/

/* ============================================
   MOBILE FOUNDATION - NO HORIZONTAL SCROLL
   ============================================ */

@media (max-width: 768px) {
    /* Prevent any horizontal overflow */
    * {
        box-sizing: border-box;
    }
    
    body {
        overflow-x: hidden; /* Prevent horizontal scroll */
        width: 100vw;
        max-width: 100vw;
    }
    
    .container {
        padding: 20px 16px;
        max-width: 100vw;
        width: 100%;
        overflow-x: hidden;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 16px 12px;
        max-width: 100vw;
    }
}

/* ============================================
   HEADER - CENTERED AND COMPACT
   ============================================ */

@media (max-width: 768px) {
    .header {
        padding: 20px 0 !important;
        margin-bottom: 20px !important;
        text-align: center !important;
    }
    
    .logo-container {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 12px !important;
        margin-bottom: 6px !important;
    }
    
    .logo-image {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .logo {
        font-size: 1.8rem; /* Kompakter aber elegant */
    }
    
    .subtitle {
        font-size: 0.9rem;
        margin-top: 4px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 16px 0;
        margin-bottom: 16px;
    }
    
    .logo-image {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .logo {
        font-size: 1.6rem;
    }
    
    .subtitle {
        font-size: 0.85rem;
    }
}

/* ============================================
   SITE NAVIGATION - COMPACT HORIZONTAL SCROLL
   ============================================ */

@media (max-width: 768px) {
    .site-nav {
        padding: 8px 0 !important;
        margin-bottom: 12px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
        white-space: nowrap !important;
        text-align: left !important;
    }
    
    .site-nav::-webkit-scrollbar {
        display: none !important;
    }
    
    .site-nav a {
        display: inline-block !important;
        margin: 0 8px !important;
        padding: 8px 12px !important;
        font-size: 0.8rem !important;
        background: rgba(255, 255, 255, 0.06) !important;
        border-radius: 8px !important;
        white-space: nowrap !important;
        transition: all 0.3s ease !important;
    }
    
    .site-nav a:hover {
        background: rgba(255, 255, 255, 0.12) !important;
        transform: translateY(-1px) !important;
    }
}

/* ============================================
   NAVIGATION BAR - COMPACT HORIZONTAL SCROLL
   ============================================ */

@media (max-width: 768px) {
    /* MOBILE NAVIGATION */
    .nav-bar {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        justify-content: flex-start !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .nav-btn {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
    }
}

@media (max-width: 480px) {
    .nav-btn {
        /* SLIGHTLY SMALLER FOR SMALL SCREENS BUT KEEP PC STYLE */
        padding: 10px 18px; /* Slightly smaller than PC's 12px 24px */
        font-size: 0.85rem; /* Slightly smaller than PC's 0.95rem */
    }
    
    .nav-bar {
        gap: 6px; /* Slightly smaller gap */
    }
}

/* ============================================
   MAIN CONTENT - EVERYTHING STACKED VERTICALLY
   ============================================ */

@media (max-width: 768px) {
    .main-content {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px;
        width: 100%;
        max-width: 100%;
    }
    
    /* Force all special layouts to single column */
    .main-content.stereo-layout,
    .main-content.time-layout,
    .main-content > * {
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
    }
}

/* ============================================
   CARDS AND PANELS - FULL WIDTH & ELEGANT
   ============================================ */

@media (max-width: 768px) {
    .control-panel,
    .frequency-display,
    .result-panel,
    .info-panel,
    .calculator-panel,
    .display-panel {
        padding: 20px;
        border-radius: 16px;
        width: 100%;
        max-width: 100%;
        margin: 0;
        /* Keep all the beautiful effects */
        background: rgba(255, 255, 255, 0.08);
        backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
        box-sizing: border-box;
    }
    
    .chord-section,
    .settings-section {
        padding: 20px;
        border-radius: 16px;
        margin-top: 24px;
        width: 100%;
        max-width: 100%;
        /* Keep beautiful styling */
        background: rgba(255, 255, 255, 0.06);
        backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
        box-sizing: border-box;
    }
}

@media (max-width: 480px) {
    .control-panel,
    .frequency-display,
    .result-panel,
    .info-panel,
    .calculator-panel,
    .display-panel {
        padding: 18px;
        border-radius: 14px;
    }
    
    .chord-section,
    .settings-section {
        padding: 18px;
        border-radius: 14px;
    }
}

/* ============================================
   TYPOGRAPHY - RESPONSIVE & ELEGANT
   ============================================ */

@media (max-width: 768px) {
    /* Large display values - scale for mobile */
    .frequency-value,
    .bpm-display,
    .delay-value,
    .file-size-display {
        font-size: 2.8rem; /* Smaller but still prominent */
        line-height: 1.1;
        margin-bottom: 8px;
        /* Keep the beautiful gradient */
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        word-break: break-word; /* Prevent overflow */
        text-align: center;
    }
    
    .frequency-unit,
    .bpm-unit,
    .delay-unit,
    .file-unit {
        font-size: 1.3rem; /* Keep proportional */
        color: #a0a0b3;
        font-weight: 300;
    }
    
    /* Section titles */
    .chord-title,
    .section-title {
        font-size: 1.7rem; /* Keep prominent */
        font-weight: 600;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        margin-bottom: 10px;
    }
    
    .chord-subtitle,
    .section-subtitle {
        color: #a0a0b3;
        font-size: 0.95rem;
    }
    
    /* Labels */
    label {
        display: block;
        margin-bottom: 12px;
        font-weight: 600;
        color: #ffffff;
        font-size: 0.95rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
}

@media (max-width: 480px) {
    .frequency-value,
    .bpm-display,
    .delay-value,
    .file-size-display {
        font-size: 2.4rem; /* Scale down for very small screens */
    }
    
    .frequency-unit,
    .bmp-unit,
    .delay-unit,
    .file-unit {
        font-size: 1.1rem;
    }
    
    .chord-title,
    .section-title {
        font-size: 1.4rem;
    }
}

/* ============================================
   FORM ELEMENTS - KEEP DESKTOP BEAUTY
   ============================================ */

@media (max-width: 768px) {
    input[type="number"],
    input[type="text"],
    input[type="email"] {
        padding: 16px; /* Keep comfortable padding */
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 12px; /* Keep rounded corners */
        color: #ffffff;
        font-family: inherit;
        font-size: 1rem;
        font-weight: 500;
        width: 100%;
        /* Keep beautiful focus effect */
        transition: all 0.3s ease;
    }
    
    input[type="number"]:focus,
    input[type="text"]:focus,
    input[type="email"]:focus {
        outline: none;
        border-color: #667eea;
        background: rgba(255, 255, 255, 0.15);
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    }
    
    select {
        padding: 16px 50px 16px 16px;
        background: rgba(255, 255, 255, 0.08);
        border: 1.5px solid rgba(255, 255, 255, 0.15);
        border-radius: 14px; /* Keep desktop border radius */
        color: #ffffff;
        font-family: inherit;
        font-size: 1rem;
        font-weight: 500;
        cursor: pointer;
        /* Keep desktop styling */
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        appearance: none;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23a0a0b3' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
        background-position: right 16px center;
        background-repeat: no-repeat;
        background-size: 16px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    
    select:hover {
        background: rgba(255, 255, 255, 0.12);
        border-color: rgba(255, 255, 255, 0.25);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    select:focus {
        outline: none;
        border-color: #667eea;
        background: rgba(255, 255, 255, 0.15);
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15), 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    /* Range sliders - keep elegant */
    input[type="range"] {
        width: 100%;
        height: 8px; /* Keep desktop thickness */
        background: rgba(255, 255, 255, 0.1);
        border-radius: 4px;
        outline: none;
        -webkit-appearance: none;
        appearance: none;
    }
    
    input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 20px; /* Keep desktop size */
        height: 20px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border-radius: 50%;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    }
    
    input[type="range"]::-moz-range-thumb {
        width: 20px;
        height: 20px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border-radius: 50%;
        cursor: pointer;
        border: none;
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    }
    
    .slider-value {
        position: absolute;
        right: 0;
        top: -32px;
        font-size: 0.9rem;
        color: #a0a0b3;
        font-weight: 500;
    }
}

/* ============================================
   BUTTONS - MAINTAIN DESKTOP ELEGANCE
   ============================================ */

@media (max-width: 768px) {
    .btn {
        padding: 16px 24px; /* Keep generous padding */
        border: none;
        border-radius: 12px; /* Keep desktop border radius */
        font-family: inherit;
        font-size: 1rem; /* Keep readable */
        font-weight: 600;
        cursor: pointer;
        transition: all 0.3s ease; /* Keep smooth animations */
        position: relative;
        overflow: hidden;
    }
    
    /* Keep all the beautiful button variants */
    .btn-primary {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    }
    
    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    }
    
    .btn-secondary {
        background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
        color: white;
        box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
    }
    
    .btn-secondary:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(245, 87, 108, 0.4);
    }
    
    .btn-accent {
        background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
        color: white;
        box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
    }
    
    .btn-accent:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(79, 172, 254, 0.4);
    }
    
    .button-group {
        display: flex;
        flex-direction: column; /* Immer vertikal für volle Breite */
        gap: 12px;
        margin-top: 24px;
        width: 100%;
    }
    
    .button-group .btn {
        width: 100%; /* Volle Breite für jeden Button */
        flex: none;
    }
    
    /* Chord button group kann horizontal bleiben da nur 2 buttons */
    .chord-button-group {
        flex-direction: row !important;
        gap: 10px;
    }
    
    .chord-button-group .btn {
        flex: 1;
    }
}

/* ============================================
   CHORD GENERATOR & ALL MULTI-COLUMN LAYOUTS
   ============================================ */

@media (max-width: 768px) {
    .chord-content {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px;
        width: 100%;
        max-width: 100%;
    }
    
    .chord-controls,
    .chord-display {
        background: rgba(255, 255, 255, 0.08);
        border-radius: 14px;
        padding: 18px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Any two-column or three-column layouts become single column */
    .stereo-controls,
    .calculator-grid,
    .results-grid,
    .time-inputs,
    .delay-times {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px;
        width: 100%;
    }
    
    .chord-presets {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 16px;
        width: 100%;
    }
    
    .chord-preset-btn {
        padding: 10px 8px;
        border: none;
        border-radius: 8px;
        font-family: inherit;
        font-size: 0.75rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.3s ease;
        background: rgba(102, 126, 234, 0.15);
        color: #ffffff;
        border: 1px solid rgba(102, 126, 234, 0.3);
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        width: 100%;
        box-sizing: border-box;
    }
    
    .chord-preset-btn:hover {
        background: rgba(102, 126, 234, 0.25);
        transform: translateY(-1px);
    }
}

@media (max-width: 480px) {
    .chord-presets {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .chord-preset-btn {
        font-size: 0.7rem;
        padding: 8px 6px;
    }
}

/* ============================================
   STATUS INDICATORS - KEEP BEAUTIFUL
   ============================================ */

@media (max-width: 768px) {
    .status-indicator {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        margin: 20px 0;
        font-size: 0.9rem;
        color: #a0a0b3;
    }
    
    .status-dot {
        width: 8px; /* Keep desktop size */
        height: 8px;
        border-radius: 50%;
        background: #4ade80;
        animation: pulse 2s infinite; /* Keep animation */
    }
    
    .status-dot.stopped {
        background: #6b7280;
        animation: none;
    }
    
    /* Keep the pulse animation */
    @keyframes pulse {
        0% { opacity: 1; }
        50% { opacity: 0.5; }
        100% { opacity: 1; }
    }
}

/* ============================================
   WAVE VISUALIZATION - KEEP ELEGANT
   ============================================ */

@media (max-width: 768px) {
    .wave-visualization {
        height: 60px; /* Keep desktop height */
        background: rgba(255, 255, 255, 0.05);
        border-radius: 8px;
        margin: 20px 0;
        position: relative;
        overflow: hidden;
    }
    
    .wave-line {
        position: absolute;
        top: 50%;
        left: 0;
        width: 100%;
        height: 2px;
        background: linear-gradient(90deg, #667eea, #764ba2); /* Keep gradient */
        transform: translateY(-50%);
        opacity: 0.3;
    }
}

/* ============================================
   SPECIAL CASES - MINIMAL ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    /* Time Display */
    .time-display-container {
        text-align: center;
    }
    
    /* Control groups */
    .control-group {
        margin-bottom: 25px; /* Keep generous spacing */
    }
    
    .control-group:last-child {
        margin-bottom: 0;
    }
    
    /* Frequency inputs */
    .frequency-inputs {
        margin-bottom: 20px;
    }
    
    .frequency-input-group {
        display: flex;
        gap: 10px;
        margin-bottom: 15px;
        align-items: center;
    }
    
    .frequency-input-group input {
        flex: 1;
        padding: 12px;
        font-size: 0.95rem;
    }
    
    .remove-btn {
        padding: 12px 16px;
        border: none;
        border-radius: 8px;
        background: rgba(248, 113, 113, 0.2);
        color: #f87171;
        cursor: pointer;
        transition: all 0.3s ease;
        font-size: 0.9rem;
        font-weight: 500;
    }
    
    .remove-btn:hover {
        background: rgba(248, 113, 113, 0.3);
        transform: translateY(-1px);
    }
    
    .add-frequency-btn {
        width: 100%;
        padding: 14px;
        border: none;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.1);
        color: #ffffff;
        cursor: pointer;
        transition: all 0.3s ease;
        font-weight: 500;
        border: 1px solid rgba(255, 255, 255, 0.2);
        margin-bottom: 20px;
    }
    
    .add-frequency-btn:hover {
        background: rgba(255, 255, 255, 0.15);
        transform: translateY(-1px);
    }
}

/* ============================================
   FORCE MOBILE LAYOUT - NO HORIZONTAL OVERFLOW
   ============================================ */

@media (max-width: 768px) {
    /* Ensure nothing can cause horizontal scroll */
    * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Force all containers to stay within bounds */
    div, section, main, header, nav, form, input, select, button {
        max-width: 100% !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Force all multi-column layouts to single column */
    .main-content,
    .chord-content,
    .stereo-controls,
    .results-grid,
    .calculator-grid,
    .time-inputs,
    .delay-times {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 12px !important;
    }
    
    /* Navigation stays horizontal scroll */
    .nav-bar,
    .site-nav {
        display: flex !important;
        overflow-x: auto !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* All cards and panels full width */
    .control-panel,
    .frequency-display,
    .result-panel,
    .info-panel,
    .calculator-panel,
    .display-panel,
    .chord-controls,
    .chord-display {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
    }
    
    /* Prevent text overflow */
    h1, h2, h3, h4, h5, h6, p, span, div {
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
}

@media (max-width: 480px) {
    /* Extra small screens - more compact */
    .container {
        padding: 16px 8px !important;
    }
    
    .control-panel,
    .frequency-display,
    .result-panel,
    .info-panel,
    .calculator-panel,
    .display-panel {
        padding: 16px !important;
    }
}