/* รีเซ็ตค่าเริ่มต้นและกำหนดตัวแปรสี */
:root {
    --bg-color: #121212;
    --panel-bg: #1e1e1e;
    --primary-color: #ff9800; /* สีส้ม Amber มองเห็นชัดเจน */
    --primary-dark: #f57c00;
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    --danger-color: #f44336;
    --success-color: #4caf50;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.app-container {
    width: 100%;
    max-width: 480px; /* ขนาดจำลองหน้าจอมือถือ */
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

header {
    text-align: center;
    padding-top: 10px;
}

header h1 {
    color: var(--primary-color);
    font-size: 2.5rem;
    letter-spacing: 1px;
}

.tagline {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Status Panel */
.status-panel {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.status-badge {
    flex: 1;
    padding: 12px;
    text-align: center;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9rem;
    background-color: var(--panel-bg);
    border: 1px solid #333;
}

.status-badge.active { color: var(--success-color); border-color: var(--success-color); }
.status-badge.disconnected { color: var(--danger-color); }
.status-badge.muted { color: var(--text-muted); }

/* Control Panel */
.control-panel {
    background-color: var(--panel-bg);
    padding: 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.room-control label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.input-group {
    display: flex;
    gap: 10px;
}

.input-group input {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #444;
    background-color: #2c2c2c;
    color: white;
    font-size: 1rem;
}

.btn-secondary {
    padding: 0 20px;
    border-radius: 8px;
    border: none;
    background-color: #444;
    color: white;
    font-weight: bold;
    cursor: pointer;
}

.btn-secondary:active { background-color: #555; }

/* ปุ่มหลัก START RIDE */
.btn-primary {
    background-color: var(--primary-color);
    color: #000;
    border: none;
    border-radius: 12px;
    padding: 20px;
    font-size: 1.5rem;
    font-weight: 900;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.3);
    transition: transform 0.1s;
}

.btn-primary:active {
    transform: scale(0.97);
    background-color: var(--primary-dark);
}

.btn-primary.stop {
    background-color: var(--danger-color);
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.3);
    color: white;
}

.btn-icon { font-size: 2rem; }

/* Settings Panel */
.settings-panel {
    background-color: var(--panel-bg);
    padding: 20px;
    border-radius: 12px;
}

.settings-panel h3 {
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item:last-child { margin-bottom: 0; }

.setting-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: bold;
}

.setting-value { color: var(--primary-color); }

/* ปรับแต่ง Slider (Range Input) ให้ใหญ่ขึ้น กดง่าย */
input[type=range] {
    width: 100%;
    height: 30px; /* พื้นที่กดใหญ่ขึ้น */
    background: transparent;
}

.hint {
    font-size: 0.8rem;
    color: #888;
    margin-top: 5px;
}


/* --- ส่วน Test Mic & Volume Meter --- */
.test-mic-section {
    margin-bottom: 20px;
}

.btn-outline {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-outline.active {
    background: var(--primary-color);
    color: #000;
    animation: pulse 1.5s infinite; /* ทำให้ปุ่มกระพริบเบาๆ ตอนกำลังเทสต์ */
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(255, 152, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0); }
}

.meter-wrapper {
    background-color: #121212;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #333;
}

.meter-container {
    width: 100%;
    height: 24px;
    background-color: #2c2c2c;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    margin-bottom: 8px;
}

.meter-fill {
    height: 100%;
    /* ไล่สีให้ดูเหมือนมาตรวัดเสียงจริง */
    background: linear-gradient(90deg, #4caf50 0%, #8bc34a 40%, #ffeb3b 70%, #f44336 100%);
    width: 0%;
    transition: width 0.05s linear; /* ทำให้แถบวิ่งเนียน ไม่กระตุก */
}

.threshold-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: #ffffff;
    box-shadow: 0 0 4px rgba(0,0,0,0.8);
    z-index: 2;
    transition: left 0.1s ease-out; /* เลื่อนตาม Slider แบบสมูท */
}

.meter-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.current-volume-text {
    font-size: 0.85rem;
    color: var(--text-main);
    font-weight: bold;
}

.divider {
    border: 0;
    height: 1px;
    background: #333;
    margin: 20px 0;
}