/* MonitorUltra Web App - Shared Styles */

:root {
    --primary: #6C5CE7;
    --primary-dark: #5849c2;
    --primary-light: #a29bfe;
    --bg: #0a0a0f;
    --bg-card: #12121a;
    --bg-elevated: #1a1a24;
    --text: #ffffff;
    --text-muted: #a0a0b0;
    --text-dim: #606070;
    --border: #2a2a3a;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #e17055;
    --info: #74b9ff;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 40px;
    padding-top: 20px;
}

.app-header img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 16px;
}

.card-elevated {
    background: var(--bg-elevated);
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-apple {
    background: white;
    color: black;
}

.btn-apple:hover:not(:disabled) {
    background: #f0f0f0;
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c0392b;
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--primary);
    background: rgba(108, 92, 231, 0.1);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

/* Status Indicator */
.status-indicator {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    position: relative;
}

.status-indicator.idle {
    background: linear-gradient(135deg, var(--bg-elevated) 0%, var(--bg-card) 100%);
    border: 2px solid var(--border);
}

.status-indicator.calibrating {
    background: linear-gradient(135deg, var(--warning) 0%, #e67e22 100%);
    animation: pulse 1.5s ease-in-out infinite;
}

.status-indicator.monitoring {
    background: linear-gradient(135deg, var(--success) 0%, #00a085 100%);
}

.status-indicator.transmitting {
    background: linear-gradient(135deg, var(--danger) 0%, #c0392b 100%);
    animation: pulse 0.8s ease-in-out infinite;
}

.status-indicator svg {
    width: 64px;
    height: 64px;
    color: white;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.9; }
}

/* Audio Level Meter */
.audio-meter-container {
    position: relative;
    margin: 16px 0;
}

.audio-meter {
    height: 24px;
    background: var(--bg-elevated);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border);
}

.audio-meter-fill {
    height: 100%;
    background: linear-gradient(90deg,
        var(--success) 0%,
        var(--success) 40%,
        var(--warning) 60%,
        var(--danger) 85%,
        #ff4444 100%
    );
    border-radius: 12px;
    transition: width 0.05s ease-out;
    width: 0%;
    box-shadow: 0 0 10px rgba(0, 184, 148, 0.5);
}

.audio-meter-fill.above-threshold {
    box-shadow: 0 0 15px rgba(225, 112, 85, 0.7);
}

/* Threshold marker */
.threshold-marker {
    position: absolute;
    top: -8px;
    bottom: -8px;
    width: 3px;
    background: var(--danger);
    border-radius: 2px;
    z-index: 10;
    box-shadow: 0 0 8px rgba(225, 112, 85, 0.8);
    transition: left 0.3s ease;
}

.threshold-marker::before {
    content: '';
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--danger);
}

.threshold-marker::after {
    content: 'THRESHOLD';
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--danger);
    white-space: nowrap;
    letter-spacing: 0.5px;
}

/* Baseline marker */
.baseline-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--text-dim);
    opacity: 0.5;
    z-index: 5;
    transition: left 0.3s ease;
}

/* Audio level segments for visual feedback */
.audio-meter-segments {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    gap: 2px;
    padding: 3px;
    pointer-events: none;
}

.audio-meter-segment {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Pairing Code Display */
.pairing-code {
    text-align: center;
    padding: 24px;
}

.pairing-code-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.pairing-code-value {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: 'SF Mono', 'Menlo', monospace;
    letter-spacing: 8px;
    color: var(--primary-light);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-item {
    background: var(--bg-elevated);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
}

.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger { color: var(--danger); }

/* Sensitivity Selector */
.sensitivity-options {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.sensitivity-btn {
    flex: 1;
    padding: 12px 8px;
    background: var(--bg-elevated);
    border: 2px solid transparent;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.sensitivity-btn:hover {
    border-color: var(--border);
    color: var(--text);
}

.sensitivity-btn.active {
    border-color: var(--primary);
    background: rgba(108, 92, 231, 0.15);
    color: var(--primary-light);
}

/* Messages */
.message {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.message.info {
    background: rgba(116, 185, 255, 0.15);
    border: 1px solid rgba(116, 185, 255, 0.3);
    color: var(--info);
}

.message.success {
    background: rgba(0, 184, 148, 0.15);
    border: 1px solid rgba(0, 184, 148, 0.3);
    color: var(--success);
}

.message.warning {
    background: rgba(253, 203, 110, 0.15);
    border: 1px solid rgba(253, 203, 110, 0.3);
    color: var(--warning);
}

.message.error {
    background: rgba(225, 112, 85, 0.15);
    border: 1px solid rgba(225, 112, 85, 0.3);
    color: var(--danger);
}

/* Loading Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Countdown Timer */
.countdown {
    font-size: 3rem;
    font-weight: 700;
    text-align: center;
    color: var(--warning);
    margin: 16px 0;
}

/* Footer */
.app-footer {
    margin-top: auto;
    padding: 24px 0;
    text-align: center;
}

.app-footer a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    margin: 0 12px;
    transition: color 0.2s;
}

.app-footer a:hover {
    color: var(--text);
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 16px;
    }

    .status-indicator {
        width: 140px;
        height: 140px;
    }

    .status-indicator svg {
        width: 56px;
        height: 56px;
    }

    .pairing-code-value {
        font-size: 2rem;
        letter-spacing: 6px;
    }
}

/* Hide elements */
.hidden {
    display: none !important;
}

/* Section labels */
.section-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

/* Wake lock indicator */
.wake-lock-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 184, 148, 0.1);
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--success);
    margin-bottom: 16px;
}

.wake-lock-status.inactive {
    background: rgba(225, 112, 85, 0.1);
    color: var(--danger);
}

.wake-lock-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}
