/* ===================================================================
   Grievance Portal — Mobile-First Styles
   Indian Tricolour Theme: Saffron #FF9933, White, Green #138808
   =================================================================== */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --saffron: #FF9933;
    --saffron-light: #FFF3E0;
    --saffron-dark: #E68A00;
    --green: #138808;
    --green-light: #E8F5E9;
    --green-dark: #0D5F06;
    --white: #FFFFFF;
    --bg: #FFFBF5;
    --text: #1A1A2E;
    --text-muted: #5A5A6E;
    --text-light: #8A8A9E;
    --red: #D32F2F;
    --red-light: #FFEBEE;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-lg: 20px;
    --radius-full: 50%;
    --transition: 0.2s ease;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Noto Sans Devanagari', 'Devanagari Sangam MN', 'Nirmala UI', 'Mangal', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---------- App Shell ---------- */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    position: relative;
}

.accent-bar {
    height: 4px;
    background: linear-gradient(90deg, var(--saffron), var(--saffron-dark), var(--saffron));
    flex-shrink: 0;
}

/* ---------- Screens ---------- */
.screen {
    display: none;
    flex: 1;
    align-items: center;
    justify-content: center;
    padding: 24px 20px 40px;
}

.screen.active {
    display: flex;
}

.screen-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    max-width: 420px;
    gap: 4px;
}

/* ---------- Landing / Idle Screen ---------- */
.hero-icon {
    margin-bottom: 8px;
}

.heading {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.35;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    line-height: 1.65;
    margin-bottom: 20px;
}

/* Microphone Button */
.mic-btn {
    width: 96px;
    height: 96px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--saffron);
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(255, 153, 51, 0.35), 0 2px 4px rgba(0,0,0,0.1);
    transition: transform var(--transition), box-shadow var(--transition);
    margin: 8px 0 12px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mic-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(255, 153, 51, 0.45), 0 2px 8px rgba(0,0,0,0.12);
}

.mic-btn:active {
    transform: scale(0.97);
}

.instruction {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
}

.lang-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 2px;
    margin-bottom: 20px;
}

.privacy-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--saffron-light);
    border: 1px solid rgba(255, 153, 51, 0.2);
    border-radius: var(--radius);
    padding: 10px 16px;
    margin-top: 12px;
}

.privacy-badge svg {
    flex-shrink: 0;
    color: var(--saffron);
}

.privacy-badge span {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: left;
    line-height: 1.5;
}

/* ---------- Recording Screen ---------- */
.recording-visual {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.rec-dot {
    width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    background: var(--red);
    position: relative;
    z-index: 2;
}

.pulse-ring {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    border: 3px solid var(--red);
    opacity: 0;
    animation: pulse-expand 2s ease-out infinite;
}

.pulse-ring-2 {
    animation-delay: 1s;
}

@keyframes pulse-expand {
    0% {
        transform: scale(0.3);
        opacity: 0.6;
    }
    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

.timer {
    font-size: 2.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    letter-spacing: 2px;
    font-family: 'Segoe UI', system-ui, sans-serif;
    margin-bottom: 4px;
}

.rec-label {
    font-size: 1rem;
    color: var(--red);
    font-weight: 600;
    margin-bottom: 2px;
}

.rec-limit {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 28px;
}

.stop-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    border-radius: var(--radius-lg);
    border: none;
    background: var(--red);
    color: var(--white);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition), background var(--transition);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-family: inherit;
}

.stop-btn:active {
    transform: scale(0.97);
    background: #B71C1C;
}

/* ---------- Preview Screen ---------- */
.preview-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}

.player-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--white);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    width: 100%;
    box-shadow: var(--shadow-sm);
}

.play-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--saffron);
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.play-btn:active {
    transform: scale(0.93);
}

.progress-track {
    flex: 1;
    height: 6px;
    background: #EEE;
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
    touch-action: manipulation;
}

.progress-fill {
    height: 100%;
    background: var(--saffron);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.playback-time {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    font-family: 'Segoe UI', system-ui, sans-serif;
    min-width: 36px;
    text-align: right;
}

.rec-meta {
    display: flex;
    gap: 20px;
    margin: 12px 0 24px;
}

.rec-meta > span {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: var(--text-light);
}

.rec-meta svg {
    color: var(--text-light);
}

/* Action buttons row */
.preview-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

/* ---------- Buttons ---------- */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    border: none;
    font-family: inherit;
    flex: 1;
}

.btn:active {
    transform: scale(0.97);
}

.btn-outline {
    background: var(--white);
    color: var(--text-muted);
    border: 1.5px solid #DDD;
}

.btn-outline:hover {
    border-color: #BBB;
    background: #FAFAFA;
}

.btn-primary {
    background: var(--saffron);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(255, 153, 51, 0.3);
}

.btn-primary:hover {
    background: var(--saffron-dark);
}

.btn-submit {
    background: var(--green);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(19, 136, 8, 0.3);
}

.btn-submit:hover {
    background: var(--green-dark);
}

/* ---------- Submitting Screen ---------- */
.upload-icon {
    margin-bottom: 16px;
}

.spin-slow {
    animation: spin 2s linear infinite;
}

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

.upload-label {
    font-size: 1.05rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 16px;
}

.upload-bar-track {
    width: 100%;
    max-width: 280px;
    height: 8px;
    background: #EEE;
    border-radius: 4px;
    overflow: hidden;
}

.upload-bar-fill {
    height: 100%;
    background: var(--saffron);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.upload-percent {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

/* ---------- Success Screen ---------- */
.success-badge {
    margin-bottom: 16px;
}

.success-msg {
    font-size: 1.1rem;
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 28px;
    font-weight: 500;
}

/* ---------- Error Screen ---------- */
.error-badge {
    margin-bottom: 16px;
}

.error-msg {
    font-size: 1.05rem;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 8px;
    font-weight: 500;
}

.error-detail {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

#screen-error .btn {
    margin-top: 16px;
    max-width: 260px;
}

/* ---------- Footer ---------- */
.footer {
    padding: 16px 24px;
    text-align: center;
    border-top: 1px solid rgba(0,0,0,0.05);
    flex-shrink: 0;
}

.footer p {
    font-size: 0.72rem;
    color: var(--text-light);
    line-height: 1.6;
    max-width: 400px;
    margin: 0 auto;
}

/* ---------- Utility ---------- */
.hidden {
    display: none !important;
}

/* ---------- Responsive: Larger Screens ---------- */
@media (min-width: 640px) {
    .heading {
        font-size: 2rem;
    }

    .mic-btn {
        width: 112px;
        height: 112px;
    }

    .mic-btn svg {
        width: 48px;
        height: 48px;
    }

    .screen {
        padding: 40px 32px 60px;
    }

    .timer {
        font-size: 3.2rem;
    }
}

/* ---------- Safe area for notched phones ---------- */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .footer {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

/* ---------- Reduce motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .pulse-ring {
        animation: none;
    }

    .spin-slow {
        animation: none;
    }

    *, *::before, *::after {
        transition-duration: 0.01ms !important;
    }
}
