/* =========================================================================
   DictationFlow - Premium UI/UX Styling
   ========================================================================= */

:root {
    /* Slightly softened background from pure black */
    --bg-main: #0c0c0e;
    --bg-panel: #141418;
    --bg-glass: rgba(20, 20, 24, 0.7);
    --border-glass: rgba(255, 255, 255, 0.08);
    --primary: #7c6df0;
    --primary-hover: #9b8ff5;
    --text-primary: #ededed;
    /* Raised dimmed text opacity to keep context visible */
    --text-dim: rgba(237, 237, 237, 0.45);
    --text-active: #ffffff;
    --shadow-glow: rgba(124, 109, 240, 0.3);

    /* Typography */
    --font-ui: 'Inter', system-ui, sans-serif;
    --font-reading: 'Merriweather', Georgia, serif;

    --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-ui);
    overflow-x: hidden;
    /* height is NOT constrained — page scrolls below the player section */
}


/* --- Player Section Container --- */
.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* --- Header --- */

.app-header {
    height: 70px;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-glass);
    background: var(--bg-panel);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
}

.logo i {
    color: var(--primary);
    font-size: 1.8rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    font-family: var(--font-ui);
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* --- Main Workspace Canvas (Document Layout) --- */
.workspace {
    flex: 1;
    min-height: 0;                  /* critical: allow flex child to shrink */
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 16px 20px 100px;       /* 100px bottom = room for floating pill */
    overflow: hidden;
}

/* Document Page Wrapper */
.document-wrapper {
    width: 100%;
    max-width: 800px;
    flex: 1;
    /* fill the workspace height */
    min-height: 0;
    /* allow shrinking */
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* The Document Canvas */
.canvas-container {
    width: 100%;
    flex: 1;
    min-height: 0;                  /* must be 0 — let flex shrink it */
    background: #1a1a20;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    position: relative;
    overflow: hidden;
}

/* Floating Edit Button */
.btn-edit {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    background: rgba(20, 20, 24, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-edit:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.glass-input,
.reader-box {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;          /* Prevent padding from expanding past 100% */
    background: transparent;
    border: none;
    outline: none;
    font-size: 1.5rem;               /* Reverting to your preferred larger font */
    line-height: 2.0;
    color: var(--text-primary);
    resize: none;
    overflow-y: auto;
    transition: opacity 0.3s ease;
}

/* Edit Mode Font */
.glass-input {
    font-family: var(--font-ui);
    font-size: 1.1rem;
    line-height: 1.85;
    padding: 32px 48px 64px 48px;    /* Extra bottom padding */
}

.glass-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

/* Read Mode Font */
.reader-box {
    font-family: var(--font-reading);
    font-size: 1.15rem;
    line-height: 1.9;
    padding: 32px 48px 64px 48px;    /* Extra bottom padding */
    opacity: 1;
    pointer-events: auto;
}

.reader-box.hidden,
.glass-input.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: -1;
}

/* Generic hidden class — for input[type="file"] and other non-canvas elements only.
   NOTE: NOT applied to .reader-box or .glass-input to preserve their opacity-based toggle. */
:not(.reader-box):not(.glass-input).hidden {
    display: none !important;
}

/* Typography & Focus Mode Highlighting */
.word {
    display: inline;
    transition: background-color 0.2s ease, opacity 0.4s ease;
    cursor: pointer;
    border-radius: 4px;
    opacity: 0.45;
    /* Softened from extreme dim */
    padding: 2px 0;
    margin: 0 1px;
}

.word:hover {
    opacity: 0.8 !important;
}

.word.spoken {
    opacity: 0.5;
    /* Already read words */
}

/* Active Highlight with "Glide" Feel */
.word.active {
    color: var(--text-active);
    opacity: 1;
    font-weight: bold;
    background-color: var(--shadow-glow);
    padding: 4px 6px;
    margin: 0 -5px;
    /* Compesates for padding to prevent layout shift */
    border-radius: 6px;
    box-shadow: 0 0 12px var(--shadow-glow);
}

/* --- Giant WPM Slider --- */
.wpm-macro-container {
    width: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wpm-macro-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
    font-weight: 500;
}

.giant-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    outline: none;
}

.giant-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    cursor: grab;
    box-shadow: 0 0 12px var(--shadow-glow);
    transition: transform 0.2s;
}

.giant-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.1);
}


/* --- Floating Pill Player --- */
.pill-player-container {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 900px;
    z-index: 100;
}

.floating-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(20, 20, 24, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: 60px;
    padding: 12px 32px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Pill Segments */
.pill-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 120px;
}

.status-badge {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary);
    font-weight: 600;
}

.progress-mini {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 5px;
}

.timer-display {
    font-variant-numeric: tabular-nums;
    /* prevents layout shift as digits change */
    letter-spacing: 0.02em;
}

.pill-separator {
    opacity: 0.4;
}

/* Playback Core */
.pill-center {
    display: flex;
    align-items: center;
    gap: 24px;
}

.control-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.8rem;
    cursor: pointer;
    transition: transform 0.2s, color 0.2s;
    opacity: 0.7;
}

.control-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.play-btn {
    background: var(--primary);
    border: none;
    color: white;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    cursor: pointer;
    box-shadow: 0 8px 16px var(--shadow-glow);
    transition: var(--transition-smooth);
}

.play-btn:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 12px 24px var(--shadow-glow);
}

/* Settings Right */
.pill-right {
    display: flex;
    align-items: center;
    gap: 24px;
    width: 250px;
    justify-content: flex-end;
}

/* Retain the voice dropdown styling in the pill */
.setting-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.2rem;
}

.voice-dropdown {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-ui);
    outline: none;
    cursor: pointer;
    max-width: 120px;
    text-overflow: ellipsis;
}

/* Top attached progress bar for pill */
.progress-bar-container {
    position: absolute;
    top: -14px;
    left: 10%;
    width: 80%;
    height: 8px;                         /* was 4px — noticeably thicker */
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    transition: height 0.15s ease;
    transform-origin: center;
}

/* Expand bar on hover for easier scrubbing */
.progress-bar-container:hover {
    height: 12px;
    top: -16px;                          /* keep it vertically centered */
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    width: 0%;
    transition: width 0.1s linear;
    border-radius: 8px;
}

/* --- Stat Chips (Words / Characters spoken) --- */
.stat-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.65);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.stat-chip i {
    color: var(--primary);
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* --- Reset Clock Button --- */
.reset-clock-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.9rem;
    padding: 0;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    transition: color 0.2s;
}
.reset-clock-btn:hover {
    color: rgba(255, 255, 255, 0.75);
}

/* Wider pill-left to accommodate chips */
.pill-left {
    width: 150px;
}

/* --- Cookie Banner --- */
.cookie-banner {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(20, 20, 24, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 24px;
    max-width: 500px;
    backdrop-filter: blur(10px);
    transition: opacity 0.3s ease;
}

.cookie-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.cookie-content i {
    color: var(--primary);
    font-size: 1.4rem;
    flex-shrink: 0;
}

.cookie-content b {
    color: #fff;
}

.cookie-content a {
    color: var(--primary);
    text-decoration: none;
}

.cookie-content a:hover {
    text-decoration: underline;
}

.btn-dismiss-cookie {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.btn-dismiss-cookie:hover {
    opacity: 0.85;
}

@media (max-width: 600px) {
    .cookie-banner {
        flex-direction: column;
        align-items: stretch;
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}