/* ==========================================================================
   Voice WAV Studio Pro - Premium Dark Mode Styling
   ========================================================================== */

:root {
    --bg-main: #0b1329;
    --bg-card: #141e38;
    --bg-card-hover: #1c2a4c;
    --border-color: rgba(255, 255, 255, 0.08);
    
    --primary-cyan: #00f5d4;
    --primary-blue: #00b4d8;
    --accent-red: #ff2a6d;
    --accent-gold: #ffb703;
    --accent-purple: #7b2cbf;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --font-main: 'Kanit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;

    --shadow-glow: 0 0 25px rgba(0, 245, 212, 0.2);
    --shadow-red: 0 0 25px rgba(255, 42, 109, 0.3);
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: stretch;
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(0, 245, 212, 0.06) 0%, transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(123, 44, 191, 0.1) 0%, transparent 45%);
    padding: 1.5rem;
}

.app-container {
    width: 100%;
    max-width: 1150px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.75rem;
    background: rgba(20, 30, 56, 0.75);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary-cyan), var(--primary-blue));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0b1329;
    font-size: 1.6rem;
    box-shadow: var(--shadow-glow);
}

.logo-text h1 {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, #ffffff, var(--primary-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge-free {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--primary-cyan);
    font-weight: 400;
}

/* Primary Small Button */
.btn-primary-sm {
    background: linear-gradient(135deg, var(--primary-cyan), var(--primary-blue));
    color: #0b1329;
    border: none;
    padding: 0.65rem 1.25rem;
    border-radius: 20px;
    font-family: var(--font-main);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-glow);
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary-sm:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(0, 245, 212, 0.4);
}

/* Main Content Grid */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 920px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #e2e8f0;
}

.quality-tag {
    font-size: 0.8rem;
    font-family: var(--font-mono);
    background: rgba(0, 245, 212, 0.1);
    color: var(--primary-cyan);
    border: 1px solid rgba(0, 245, 212, 0.25);
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
}

/* Device Bar */
.device-bar {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Settings Bar */
.settings-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.25);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
    min-width: 140px;
}

.setting-group.full-width {
    min-width: 100%;
}

.setting-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.custom-select {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-main);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.custom-select:focus {
    border-color: var(--primary-cyan);
}

/* Range Slider */
.custom-range {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #0f172a;
    outline: none;
    margin-top: 0.35rem;
}

.custom-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-cyan);
    cursor: pointer;
    box-shadow: 0 0 10px var(--primary-cyan);
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 0.6rem;
    min-width: 100%;
    margin-top: 0.25rem;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #334155;
    transition: .3s;
    border-radius: 22px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary-cyan);
}

input:checked + .slider:before {
    transform: translateX(18px);
    background-color: #0b1329;
}

.toggle-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    cursor: pointer;
}

/* Visualizer Canvas Area */
.visualizer-container {
    position: relative;
    width: 100%;
    height: 200px;
    background: #060b18;
    border: 1px solid rgba(0, 245, 212, 0.2);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.85);
}

#visualizerCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.visualizer-overlay {
    position: absolute;
    top: 14px;
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
}

.timer-display {
    font-family: var(--font-mono);
    font-size: 1.85rem;
    font-weight: 600;
    color: #ffffff;
    text-shadow: 0 0 12px rgba(0, 245, 212, 0.6);
    letter-spacing: 1px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(6px);
    padding: 0.35rem 0.8rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #64748b;
    transition: all 0.3s ease;
}

.status-indicator.recording .status-dot {
    background-color: var(--accent-red);
    box-shadow: var(--shadow-red);
    animation: pulse 1s infinite alternate;
}

.status-indicator.paused .status-dot {
    background-color: var(--accent-gold);
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.8; }
    100% { transform: scale(1.25); opacity: 1; }
}

/* VU Meter Bar */
.vu-meter-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
}

.vu-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    min-width: 55px;
}

.vu-bar-wrapper {
    flex: 1;
    height: 10px;
    background: #0f172a;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.vu-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #00f5d4 0%, #ffb703 75%, #ff2a6d 100%);
    border-radius: 5px;
    transition: width 0.05s ease-out;
}

.vu-value {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-dim);
    min-width: 48px;
    text-align: right;
}

/* Controls Area */
.controls-area {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    margin-top: 0.5rem;
}

.btn-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: none;
    border-radius: 16px;
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    padding: 0.9rem 1.4rem;
    min-width: 105px;
}

.btn-record {
    background: linear-gradient(135deg, #ff2a6d, #d90429);
    color: white;
    box-shadow: 0 4px 18px rgba(255, 42, 109, 0.4);
}

.btn-record:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(255, 42, 109, 0.6);
}

.btn-record i {
    font-size: 1.3rem;
}

.btn-pause {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

.btn-pause:hover:not(:disabled) {
    background: #334155;
}

.btn-stop {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

.btn-stop:hover:not(:disabled) {
    background: #334155;
    color: var(--accent-red);
}

.btn-control:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* History Card & Recording Item */
.count-badge {
    background: rgba(255, 255, 255, 0.08);
    padding: 0.2rem 0.65rem;
    border-radius: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.recording-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    max-height: 520px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.recording-list::-webkit-scrollbar {
    width: 6px;
}
.recording-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.empty-icon {
    font-size: 2.5rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.empty-sub {
    font-size: 0.82rem;
    color: var(--text-dim);
}

.recording-item {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: all 0.2s ease;
}

.recording-item:hover {
    border-color: rgba(0, 245, 212, 0.35);
    background: rgba(0, 0, 0, 0.35);
}

.item-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.item-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.item-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: #ffffff;
    word-break: break-all;
}

.item-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.item-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--primary-cyan);
    color: #0b1329;
    border-color: var(--primary-cyan);
}

.btn-icon.btn-delete:hover {
    background: var(--accent-red);
    color: white;
    border-color: var(--accent-red);
}

.item-player {
    width: 100%;
    margin-top: 0.25rem;
}

.item-player audio {
    width: 100%;
    height: 36px;
    border-radius: 8px;
    filter: invert(0.9) hue-rotate(180deg);
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.8rem;
    color: var(--text-dim);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--primary-cyan);
    padding: 0.8rem 1.25rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9999;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* ==========================================================================
   RESPONSIVE - Tablet Small (max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {
    body {
        padding: 0.75rem;
    }

    .app-container {
        gap: 1rem;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 1rem 1.25rem;
    }

    .header-actions {
        width: 100%;
    }

    .btn-primary-sm {
        width: 100%;
        justify-content: center;
    }

    .logo-text h1 {
        font-size: 1.3rem;
    }

    .badge-free {
        font-size: 0.7rem;
        line-height: 1.4;
        flex-wrap: wrap;
    }

    .card {
        padding: 1.25rem;
        border-radius: var(--radius-md);
        gap: 1rem;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .card-header h2 {
        font-size: 1.05rem;
    }

    .quality-tag {
        font-size: 0.72rem;
        padding: 0.2rem 0.5rem;
    }

    .settings-bar {
        padding: 0.75rem;
        gap: 0.85rem;
    }

    .setting-group {
        min-width: 100%;
        flex: unset;
    }

    .visualizer-container {
        height: 160px;
    }

    .timer-display {
        font-size: 1.4rem;
    }

    .status-indicator {
        font-size: 0.75rem;
        padding: 0.25rem 0.6rem;
    }

    .controls-area {
        gap: 0.75rem;
    }

    .btn-control {
        min-width: 90px;
        padding: 0.75rem 1rem;
        font-size: 0.8rem;
        border-radius: 12px;
    }

    .recording-list {
        max-height: none;
    }

    .item-main {
        flex-direction: column;
        gap: 0.6rem;
    }

    .item-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .btn-icon {
        width: 40px;
        height: 40px;
    }

    .toast {
        left: 12px;
        right: 12px;
        bottom: 16px;
    }

    .app-footer p {
        font-size: 0.72rem;
        line-height: 1.5;
    }
}

/* ==========================================================================
   RESPONSIVE - Phone (max-width: 480px)
   ========================================================================== */
@media (max-width: 480px) {
    body {
        padding: 0.5rem;
    }

    .app-container {
        gap: 0.75rem;
    }

    .app-header {
        padding: 0.85rem 1rem;
        border-radius: 12px;
    }

    .logo-area {
        gap: 0.75rem;
    }

    .logo-icon {
        width: 42px;
        height: 42px;
        font-size: 1.3rem;
        border-radius: 12px;
    }

    .logo-text h1 {
        font-size: 1.15rem;
    }

    .badge-free {
        font-size: 0.65rem;
    }

    .card {
        padding: 1rem;
        border-radius: 14px;
        gap: 0.85rem;
    }

    .card-header h2 {
        font-size: 0.95rem;
        gap: 0.4rem;
    }

    .quality-tag {
        font-size: 0.68rem;
    }

    .device-bar {
        padding: 0.65rem 0.75rem;
    }

    .settings-bar {
        padding: 0.65rem;
        gap: 0.75rem;
    }

    .setting-group label {
        font-size: 0.75rem;
    }

    .custom-select {
        font-size: 0.8rem;
        padding: 0.45rem 0.6rem;
    }

    .toggle-label {
        font-size: 0.75rem;
    }

    .visualizer-container {
        height: 140px;
        border-radius: 12px;
    }

    .visualizer-overlay {
        top: 8px;
        left: 10px;
        right: 10px;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .timer-display {
        font-size: 1.25rem;
    }

    .status-indicator {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }

    .vu-meter-container {
        padding: 0.5rem 0.65rem;
        gap: 0.5rem;
    }

    .vu-label {
        font-size: 0.7rem;
        min-width: 45px;
    }

    .vu-value {
        font-size: 0.68rem;
        min-width: 42px;
    }

    .controls-area {
        gap: 0.6rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .btn-control {
        min-width: 80px;
        padding: 0.7rem 0.85rem;
        font-size: 0.78rem;
        border-radius: 12px;
        flex: 1;
        max-width: 120px;
    }

    .btn-record i {
        font-size: 1.1rem;
    }

    .recording-item {
        padding: 0.85rem;
    }

    .item-title {
        font-size: 0.85rem;
    }

    .item-meta {
        font-size: 0.7rem;
        gap: 0.5rem;
    }

    .item-player audio {
        height: 32px;
    }

    .btn-icon {
        width: 38px;
        height: 38px;
        border-radius: 8px;
    }

    .empty-state {
        padding: 2rem 0.75rem;
    }

    .empty-icon {
        font-size: 2rem;
    }

    .empty-sub {
        font-size: 0.75rem;
    }

    .toast {
        left: 8px;
        right: 8px;
        bottom: 12px;
        font-size: 0.8rem;
        padding: 0.65rem 1rem;
        border-radius: 10px;
    }

    .app-footer {
        padding: 0.75rem 0.5rem;
    }

    .app-footer p {
        font-size: 0.68rem;
    }

    .count-badge {
        font-size: 0.72rem;
    }
}

/* ==========================================================================
   RESPONSIVE - Very Small Phone (max-width: 360px)
   ========================================================================== */
@media (max-width: 360px) {
    body {
        padding: 0.35rem;
    }

    .logo-icon {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
        border-radius: 10px;
    }

    .logo-text h1 {
        font-size: 1rem;
    }

    .badge-free {
        font-size: 0.6rem;
    }

    .card {
        padding: 0.85rem;
    }

    .card-header h2 {
        font-size: 0.88rem;
    }

    .visualizer-container {
        height: 120px;
    }

    .timer-display {
        font-size: 1.1rem;
    }

    .btn-control {
        min-width: 70px;
        padding: 0.6rem 0.7rem;
        font-size: 0.72rem;
    }

    .controls-area {
        gap: 0.5rem;
    }
}

/* ==========================================================================
   Safe Area Insets for notched phones (iPhone X+, Samsung S-series)
   ========================================================================== */
@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
        padding-left: calc(0.5rem + env(safe-area-inset-left));
        padding-right: calc(0.5rem + env(safe-area-inset-right));
    }

    .toast {
        bottom: calc(12px + env(safe-area-inset-bottom));
    }
}
