/* ==================== Mobile Responsive Styles ==================== */
/* Breakpoints: 768px (tablet), 480px (mobile) */

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.mobile-menu-toggle:hover {
    background: var(--panel-bg);
}

.mobile-menu-toggle .icon {
    width: 24px;
    height: 24px;
}

/* Sidebar Overlay (for mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
}

/* ==================== Tablet Styles (max-width: 768px) ==================== */
@media (max-width: 768px) {
    /* Show mobile menu toggle */
    .mobile-menu-toggle {
        display: flex;
    }

    /* Show sidebar overlay */
    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }

    .sidebar-overlay.active {
        pointer-events: auto;
    }

    /* ==================== Global Header ==================== */
    .global-header {
        padding: 0 12px !important;
        height: 56px;
        gap: 8px;
    }

    .logo-area {
        font-size: 16px;
        gap: 6px;
        flex-shrink: 1;
        min-width: 0;
    }

    .logo-area svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    .logo-area span {
        display: none;
    }

    /* Header Controls - Hide non-essential items */
    .header-controls {
        gap: 8px !important;
        flex-shrink: 0;
    }

    .header-controls .upgrade-btn,
    .header-controls #langSwitcherContainer {
        display: none !important;
    }

    .header-controls #quotaDisplay {
        display: none;
    }

    .header-controls #themeToggle {
        width: 36px;
        height: 36px;
        padding: 6px;
    }

    .header-controls #authBtn {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* ==================== App Container ==================== */
    .app-container {
        height: calc(100vh - 56px);
    }

    /* ==================== Sidebar - Off-canvas on mobile ==================== */
    .sidebar-left {
        position: fixed;
        top: 56px;
        left: 0;
        height: calc(100vh - 56px);
        width: 280px;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }

    .sidebar-left.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }

    /* Hide sidebar toggle in mobile (use hamburger instead) */
    .sidebar-left .sidebar-toggle {
        display: none;
    }

    /* ==================== Main Content ==================== */
    .main-content {
        padding: 16px !important;
        width: 100%;
        max-width: 100% !important;
    }

    /* ==================== Home View ==================== */
    #homeContainer {
        padding: 0;
    }

    .welcome-section {
        margin-bottom: 20px;
    }

    .welcome-section h1 {
        font-size: 24px !important;
    }

    .welcome-section p {
        font-size: 14px;
    }

    .creation-tabs {
        margin-bottom: 20px;
    }

    .creation-tab {
        padding: 8px 14px;
        font-size: 12px;
    }

    /* Main Card */
    .main-card {
        margin-bottom: 32px;
        min-height: auto;
    }

    .card-content {
        padding: 20px !important;
    }

    .home-textarea {
        min-height: 150px !important;
        font-size: 15px !important;
    }

    /* Preset Buttons */
    .preset-buttons {
        gap: 8px;
    }

    .preset-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    .preset-btn span {
        display: none;
    }

    .preset-btn svg {
        margin: 0;
    }

    /* Controls Area */
    .controls-area {
        flex-direction: column !important;
        gap: 16px !important;
        align-items: stretch !important;
    }

    .controls-left {
        flex-wrap: wrap;
        gap: 8px !important;
        justify-content: flex-start;
    }

    .controls-right {
        width: 100%;
    }

    .controls-right .generate-btn-pill {
        width: 100%;
        justify-content: center;
    }

    .control-item {
        padding: 8px 10px;
        font-size: 13px;
    }

    .control-item .voice-avatar-xs {
        width: 20px;
        height: 20px;
    }

    /* Voice Selector - Truncate text */
    #homeVoiceSelector {
        max-width: 140px;
        overflow: hidden;
    }

    #homeCurrentVoiceName {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 80px;
    }

    /* AI Voice Button */
    .control-item.ai-voice-btn span {
        display: none;
    }

    /* Audio Tools Section */
    .audio-tools-section {
        margin-bottom: 32px;
    }

    .section-title {
        font-size: 18px;
        margin-bottom: 16px;
    }

    .tools-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .tool-card {
        min-height: auto;
    }

    .tool-card-content {
        flex-direction: column !important;
        padding: 20px !important;
        gap: 16px;
    }

    .tool-info {
        padding-right: 0 !important;
    }

    .tool-info h4 {
        font-size: 18px;
    }

    .tool-info p {
        font-size: 13px;
        margin-bottom: 16px;
    }

    .tool-visual {
        justify-content: flex-start;
        width: 100%;
    }

    /* Visual Design chat bubbles - horizontal layout on mobile */
    .visual-design {
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 8px !important;
        width: 100%;
        max-width: none !important;
    }

    .visual-design .chat-bubble {
        flex-shrink: 0;
    }

    /* Visual Clone - horizontal on mobile */
    .visual-clone {
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 8px !important;
        align-items: center;
    }

    .visual-clone .arrow-connector {
        width: 20px;
        height: 2px;
        transform: rotate(0deg);
    }

    .visual-clone .arrow-connector::after {
        top: -3px;
        left: auto;
        right: 0;
        border-top: 4px solid transparent;
        border-bottom: 4px solid transparent;
        border-left: 6px solid #d1d5db;
        border-right: none;
    }

    /* Voice Recommendations */
    .voice-recommendations {
        margin-top: 32px;
    }

    .voice-recommendations .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .voice-recommendations h3 {
        font-size: 18px;
    }

    /* Voice Grid - 3 columns on tablet */
    .voice-grid-horizontal {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 14px !important;
    }

    /* Home Sample Cards - Premium Audio Design (Tablet) */
    .home-sample-card:hover {
        transform: translateY(-4px) scale(1.01);
    }

    .sample-visual {
        border-radius: 16px;
    }

    /* Pattern adjustments for tablet */
    .pattern-waveform {
        gap: 4px;
    }

    .pattern-waveform .wave-bar {
        width: 5px;
    }

    .pattern-dots {
        gap: 10px;
    }

    .pattern-circles .center-icon {
        width: 16px;
        height: 16px;
    }

    .pattern-zigzag {
        gap: 12px;
    }

    .pattern-zigzag .zigzag-line {
        height: 5px;
    }

    /* Play button - tablet */
    .sample-play-btn {
        width: 34px;
        height: 34px;
        border-radius: 8px;
    }

    .sample-play-btn svg {
        width: 13px;
        height: 13px;
    }

    /* Card info section */
    .sample-info {
        padding: 12px 2px 4px;
    }

    .sample-title {
        font-size: 13px;
    }

    .sample-tags {
        gap: 5px;
    }

    .sample-tag {
        font-size: 10px;
        padding: 2px 6px;
    }

    /* ==================== Text to Speech View ==================== */
    #textToSpeechContainer {
        height: auto !important;
        overflow: visible !important;
    }

    /* TTS Top Bar */
    #textToSpeechContainer > .top-bar,
    #textToSpeechContainer > div:first-child {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
        margin-bottom: 16px !important;
    }

    #textToSpeechContainer .page-title {
        font-size: 20px !important;
    }

    #textToSpeechContainer .model-selector {
        font-size: 13px;
    }

    /* TTS Main Layout - Stack vertically */
    #textToSpeechContainer > div[style*="display: flex"][style*="gap: 24px"] {
        flex-direction: column !important;
        gap: 16px !important;
        overflow: visible !important;
    }

    /* TTS Editor Area */
    #textToSpeechContainer > div > div[style*="flex: 1"][style*="flex-direction: column"] {
        width: 100% !important;
    }

    #textToSpeechContainer > div > div > div[style*="position: relative"] {
        padding: 16px !important;
        min-height: 200px;
    }

    .text-editor,
    #ttsTextInput {
        font-size: 15px !important;
        min-height: 150px !important;
    }

    #pauseHint {
        display: none !important;
    }

    /* TTS Bottom Toolbar */
    #textToSpeechContainer > div > div > div[style*="display: flex"][style*="justify-content: space-between"][style*="margin-top: 16px"] {
        flex-direction: column !important;
        gap: 12px !important;
        align-items: stretch !important;
    }

    #textToSpeechContainer > div > div > div[style*="margin-top: 16px"] > div {
        justify-content: center !important;
        flex-wrap: wrap !important;
    }

    /* TTS Right Sidebar - Full width on mobile */
    #textToSpeechContainer > div > div[style*="width: 280px"] {
        width: 100% !important;
        flex-shrink: 1 !important;
    }

    /* TTS Settings Tabs */
    #textToSpeechContainer .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #textToSpeechContainer .tab {
        padding: 12px 8px !important;
        font-size: 13px !important;
        white-space: nowrap;
    }

    /* Settings Content */
    .settings-content {
        padding: 16px !important;
    }

    /* ==================== Voice Library ==================== */
    .voice-library-container {
        padding: 0;
    }

    /* Library Banners - Stack on mobile */
    .library-banners {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        margin-bottom: 24px !important;
    }

    .lib-banner {
        padding: 16px !important;
    }

    /* Voice Filter Bar */
    .voice-filter-bar {
        flex-direction: column;
        gap: 12px;
    }

    .voice-search-input {
        width: 100%;
    }

    .voice-filter-tags {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Voice Cards Grid */
    .voice-cards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .voice-card {
        padding: 12px;
    }

    /* ==================== Dubbing View ==================== */
    .dubbing-upload-area {
        padding: 24px 16px;
    }

    .dubbing-file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .dubbing-file-actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* ==================== Subscription/Pricing ==================== */
    .pricing-cards {
        flex-direction: column;
        gap: 16px;
    }

    .pricing-card {
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
    }

    /* ==================== Modals ==================== */
    .modal-overlay {
        padding: 16px;
    }

    .modal-content,
    .dialog-content {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        max-height: calc(100vh - 32px);
        border-radius: 16px;
    }

    .ai-voice-modal {
        width: 100% !important;
        max-width: none !important;
    }

    .modal-header,
    .dialog-header {
        padding: 16px;
    }

    .modal-body,
    .dialog-body {
        padding: 16px;
    }

    .modal-footer,
    .dialog-footer {
        padding: 16px;
        flex-direction: column;
        gap: 8px;
    }

    .modal-footer button,
    .dialog-footer button {
        width: 100%;
    }

    /* ==================== Toast Notifications ==================== */
    .toast {
        top: auto;
        bottom: 16px;
        right: 16px;
        left: 16px;
        min-width: auto;
        max-width: none;
    }

    /* ==================== Player ==================== */
    .audio-player {
        padding: 12px;
    }

    .player-controls {
        gap: 8px;
    }

    #persistentPlayerBar {
        padding: 8px 12px;
    }

    /* ==================== Buttons ==================== */
    .generate-btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .tool-btn {
        padding: 8px 10px;
        font-size: 12px;
    }
}

/* ==================== Mobile Styles (max-width: 480px) ==================== */
@media (max-width: 480px) {
    /* Global Header */
    .global-header {
        padding: 0 8px !important;
        height: 52px;
    }

    .logo-area {
        font-size: 14px;
    }

    /* App Container */
    .app-container {
        height: calc(100vh - 52px);
    }

    /* Sidebar */
    .sidebar-left {
        top: 52px;
        height: calc(100vh - 52px);
        width: 100%;
        max-width: 300px;
    }

    /* Main Content */
    .main-content {
        padding: 12px !important;
    }

    /* Home View */
    .welcome-section h1 {
        font-size: 20px !important;
    }

    .card-content {
        padding: 16px !important;
    }

    /* Controls */
    .controls-left {
        width: 100%;
    }

    .control-item {
        flex: 1;
        min-width: 0;
        justify-content: center;
    }

    /* Hide voice name, show only avatar */
    #homeCurrentVoiceName {
        display: none;
    }

    /* Voice Grid - 2 columns on mobile */
    .voice-grid-horizontal {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    /* Home Sample Cards - Premium Audio Design (Mobile) */
    .sample-visual {
        border-radius: 14px;
    }

    .pattern-waveform {
        gap: 3px;
    }

    .pattern-waveform .wave-bar {
        width: 4px;
    }

    .pattern-dots {
        gap: 8px;
    }

    .pattern-circles .circle {
        border-width: 1.5px;
    }

    .pattern-circles .center-icon {
        width: 14px;
        height: 14px;
    }

    .pattern-zigzag {
        gap: 10px;
    }

    .pattern-zigzag .zigzag-line {
        height: 4px;
    }

    /* Play button - mobile */
    .sample-play-btn {
        width: 32px;
        height: 32px;
        left: 10px;
        bottom: 10px;
        border-radius: 8px;
        opacity: 1;
        transform: scale(1);
    }

    .sample-play-btn svg {
        width: 12px;
        height: 12px;
    }

    /* Card info section */
    .sample-info {
        padding: 10px 2px 4px;
    }

    .sample-title {
        font-size: 12px;
        -webkit-line-clamp: 1;
    }

    .sample-tags {
        gap: 4px;
    }

    .sample-tag {
        font-size: 9px;
        padding: 3px 6px;
    }

    .voice-cards-grid {
        grid-template-columns: 1fr !important;
    }

    /* TTS View */
    #textToSpeechContainer .page-title {
        font-size: 18px !important;
    }

    /* Nav items in sidebar */
    .nav-item {
        padding: 12px;
        font-size: 15px;
    }

    /* Buttons */
    .generate-btn,
    .generate-btn-pill {
        width: 100%;
        justify-content: center;
    }

    /* Toast */
    .toast {
        bottom: 12px;
        right: 12px;
        left: 12px;
        padding: 14px 16px;
    }

    .toast-title {
        font-size: 14px;
    }

    .toast-message {
        font-size: 12px;
    }

    /* App Header */
    .app-header h1 {
        font-size: 20px;
    }
}

/* ==================== Extra Small Mobile (max-width: 360px) ==================== */
@media (max-width: 360px) {
    /* Voice Grid - Single column on very small screens */
    .voice-grid-horizontal {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .sample-visual {
        border-radius: 16px;
    }

    .pattern-waveform .wave-bar {
        width: 5px;
    }

    .pattern-dots {
        gap: 10px;
    }

    .pattern-circles .center-icon {
        width: 16px;
        height: 16px;
    }

    .sample-play-btn {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    .sample-play-btn svg {
        width: 14px;
        height: 14px;
    }

    .sample-title {
        font-size: 14px;
        -webkit-line-clamp: 2;
    }

    .sample-tag {
        font-size: 10px;
        padding: 4px 8px;
    }
}

/* ==================== Large Tablet (max-width: 1024px) ==================== */
@media (max-width: 1024px) and (min-width: 769px) {
    /* Voice Grid - 4 columns on large tablet */
    .voice-grid-horizontal {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 16px !important;
    }

    .sample-visual {
        border-radius: 18px;
    }

    .pattern-waveform .wave-bar {
        width: 5px;
    }

    .pattern-dots {
        gap: 11px;
    }

    .sample-play-btn {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    .sample-title {
        font-size: 13px;
    }

    .sample-tag {
        font-size: 10px;
    }
}

/* ==================== Utility Classes ==================== */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .show-mobile-only {
        display: none !important;
    }
}

/* ==================== Touch-friendly adjustments ==================== */
@media (max-width: 768px) {
    /* Larger touch targets */
    button, 
    .btn,
    .nav-item,
    .control-item,
    .voice-card,
    .tool-card {
        min-height: 44px;
    }

    /* Prevent text selection on UI elements */
    .nav-item,
    .control-item,
    .tab,
    .preset-btn {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Smooth scrolling */
    .main-content,
    .settings-content,
    .voice-dropdown-list {
        -webkit-overflow-scrolling: touch;
    }
}
