:root {
    /* Base Colors */
    --primary-color: #1e3c72;
    --secondary-color: #2a5298;
    --accent-color: #4f46e5;
    --accent-glow: rgba(79, 70, 229, 0.4);

    /* Gradients */
    --primary-gradient: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    --glass-gradient: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.7) 100%);

    /* Backgrounds */
    --bg-light: #f8fafc;
    --bg-white: #ffffff;

    /* Text */
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-white: #ffffff;

    /* Glassmorphism Tokens */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);

    /* Layout */
    --sidebar-width: 200px;
    --sidebar-collapsed-width: 56px;
    --navbar-height: 60px;
    --radius-lg: 16px;
    --radius-md: 12px;
}

/* Base Styles */
body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    overflow-x: hidden;
}

/* Glassmorphism Component */
.glass-effect {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* Navbar Premium Styling */
.navbar-custom {
    height: var(--navbar-height);
    background: var(--primary-gradient) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: none;
    z-index: 1030;
}

.navbar-custom .navbar-brand {
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: -0.5px;
    color: white !important;
}

.navbar-custom .nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
    font-weight: 500;
    transition: all 0.2s;
}

.navbar-custom .nav-link:hover {
    color: white !important;
}

/* Sidebar Styling */
.sidebar-custom {
    background: white !important;
    border-right: 1px solid rgba(0, 0, 0, 0.05) !important;
    z-index: 1050;
}

@media (min-width: 768px) {
    .sidebar-custom {
        position: sticky;
        top: var(--navbar-height);
        height: calc(100vh - var(--navbar-height));
        overflow-y: auto;
        overflow-x: hidden;
        padding-top: 1rem !important;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(107, 114, 128, 0.8);
}

/* Main Content Area */
main {
    overflow-x: hidden;
    min-height: calc(100vh - var(--navbar-height));
}

.sidebar-custom .nav-link {
    margin: 0.1rem 0.6rem;
    padding: 0.2rem 0.8rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-divider {
    height: 0;
    margin: 0.5rem 1rem;
    overflow: hidden;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.sidebar-heading {
    padding: 0.25rem 1rem 0.25rem 1rem;
    margin-top: 0.25rem;
    font-size: 0.7rem;
    font-weight: 800;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
}

.sidebar-custom .nav-link i {
    width: 20px;
    text-align: center;
}

.sidebar-custom .nav-link:hover {
    background: rgba(30, 60, 114, 0.04);
    color: var(--primary-color);
    transform: translateX(4px);
}

.sidebar-custom .nav-link.active {
    background: rgba(30, 60, 114, 0.08);
    color: var(--primary-color);
    font-weight: 700;
}

/* Offcanvas Overrides for Sidebar */
.offcanvas-md.sidebar-custom {
    width: var(--sidebar-width);
}

@media (max-width: 767.98px) {
    .offcanvas-md.sidebar-custom {
        width: 280px;
        border-right: none !important;
    }
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    position: absolute;
    right: -14px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    z-index: 1040;
    color: var(--primary-color);
    transition: all 0.2s ease, top 0.3s ease;
}

.sidebar-toggle-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-50%) scale(1.1);
}

/* Sidebar Collapse Logic */
@media (min-width: 768px) {
    .sidebar-custom {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    body.sidebar-collapsed #sidebarMenu {
        width: var(--sidebar-collapsed-width) !important;
        min-width: var(--sidebar-collapsed-width) !important;
        flex: 0 0 var(--sidebar-collapsed-width) !important;
        max-width: var(--sidebar-collapsed-width) !important;
        padding-top: 1.5rem;
        transition: all 0.3s ease;
        overflow-x: hidden !important;
        overflow-y: hidden !important;
    }

    body.sidebar-collapsed #sidebarMenu .nav-link {
        justify-content: center;
        padding: 0.8rem 0;
        margin: 0.25rem 0.5rem;
        gap: 0;
    }

    body.sidebar-collapsed #sidebarMenu .nav-link span,
    body.sidebar-collapsed #sidebarMenu h6,
    body.sidebar-collapsed #sidebarMenu .sidebar-heading,
    body.sidebar-collapsed #sidebarMenu .px-4,
    body.sidebar-collapsed #sidebarMenu .mt-4,
    body.sidebar-collapsed #sidebarMenu .mt-5,
    body.sidebar-collapsed #sidebarMenu .mb-2,
    body.sidebar-collapsed #sidebarMenu .mb-4,
    body.sidebar-collapsed #sidebarMenu .fa-crown {
        display: none !important;
    }
}

/* Card Styling */
.card-custom {
    border: none;
    border-radius: var(--radius-lg);
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

.card-custom:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.card-header-custom {
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding: 1.5rem;
    font-weight: 700;
}

/* Buttons */
.btn-primary-theme {
    background: var(--primary-gradient);
    border: none;
    color: white;
    border-radius: 50px;
    padding: 0.6rem 1.8rem;
    font-weight: 600;
    box-shadow: 0 4px 14px 0 rgba(30, 60, 114, 0.39);
    transition: all 0.2s;
}

.btn-primary-theme:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(30, 60, 114, 0.23);
    filter: brightness(1.1);
    color: white;
}

.btn-pill {
    border-radius: 50px;
}

/* Form Controls */
.form-control-custom {
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
}

.form-control-custom:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px var(--accent-glow);
    outline: none;
}

/* Common Utilities */
.text-gradient {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.section-title {
    font-weight: 800;
    font-size: 1.75rem;
    letter-spacing: -0.025em;
    margin-bottom: 1.5rem;
}

/* =========================================
   Unified Mic Component
   ========================================= */

.mic-unified-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 64px;
    /* Ensure wrapper fit */
    margin: 0 auto;
    z-index: 100;
}

.mic-unified-ripple {
    position: absolute;
    top: 0;
    left: 0;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid rgba(239, 68, 68, 0.5);
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}

.mic-unified-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #ef4444;
    border: none;
    color: white;
    box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.4);
    z-index: 10;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    cursor: pointer;
    padding: 0;
    position: relative;
}

.mic-unified-btn:hover {
    background: #dc2626;
    transform: scale(1.05);
    box-shadow: 0 12px 20px -3px rgba(239, 68, 68, 0.5);
}

.mic-unified-btn:active {
    transform: scale(0.95);
}

.mic-unified-btn:disabled {
    background: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
}

.mic-unified-wrapper.recording .mic-unified-btn {
    background: #dc2626;
    transform: scale(1.1);
}

.mic-unified-wrapper.recording .mic-unified-ripple {
    animation: unified-mic-ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.mic-unified-wrapper.processing .mic-unified-btn {
    background: #64748b;
    pointer-events: none;
}

.mic-unified-wrapper.processing .mic-unified-ripple {
    display: none;
}

.mic-unified-label {
    /* Optional: Label styling if used */
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e2e8f0;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    color: #64748b;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    white-space: nowrap;
    text-align: center;
}

@keyframes unified-mic-ping {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

.mic-unified-btn i {
    pointer-events: none;
}


/* =========================================
   Restored Layout Styles
   ========================================= */

.balanced-action-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    width: 100%;
    margin-top: 20px;
}

.action-buttons-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    height: 64px;
}

.compact-action-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.action-main-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    position: relative;
    /* Ensure action row is tall enough for absolute volume bar */
    min-height: 64px;
}

/* =========================================
   Global Volume Indicator (V2)
   ========================================= */

.volume-module-v2 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 32px;
    padding: 0 10px;
    border-radius: 12px;
    min-width: 80px;
    transition: all 0.3s ease;
    background: rgba(0, 0, 0, 0.02);
}

.volume-indicator-bars {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 100%;
}

.volume-v-bar {
    display: block;
    width: 4px;
    height: 4px;
    background-color: #cbd5e1;
    border-radius: 4px;
    transition: all 0.1s ease;
}

.volume-v-bar.active {
    background-color: #ef4444;
    /* Unified Red */
    height: 14px;
}

.volume-v-bar.active.medium {
    /* background-color: #10b981; Removed for single color */
    height: 22px;
}

.volume-v-bar.active.high {
    /* background-color: #ef4444; Kept implicit */
    height: 30px;
}

/* Mic Test Modal Compatibility */
.test-volume-bar {
    width: 4px;
    height: 4px;
    background-color: #cbd5e1;
    border-radius: 4px;
    transition: all 0.1s ease;
}

.test-volume-bar.active {
    background-color: #ef4444;
    /* Unified Red */
    height: 14px;
}

.test-volume-bar.active.medium {
    /* background-color: #10b981; Removed */
    height: 22px;
}

.test-volume-bar.active.high {
    /* background-color: #ef4444; Removed */
    height: 30px;
}

/* Mobile Optimizations */
@media (max-width: 767.98px) {
    :root {
        --navbar-height: 56px;
    }

    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

    main {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .section-title {
        font-size: 1.4rem;
        margin-bottom: 1rem;
    }

    .card-header-custom {
        padding: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Navbar adjustments */
    .navbar-custom .navbar-brand {
        font-size: 1.1rem;
    }

    .nav-feedback-btn {
        padding: 0.3rem 0.8rem !important;
        font-size: 0.75rem;
    }
}