/**
 * design-system-ext.css
 * DogovorAI — Material Design Extended Palette & Component Extensions
 *
 * PURPOSE: Additive stylesheet — appended on top of style.css.
 *          Never modifies existing rules, only extends them.
 *
 * Load order: <link rel="stylesheet" href="/static/css/style.css">
 *             <link rel="stylesheet" href="/static/css/design-system-ext.css">
 */

/* ============================================================
   1. EXTENDED CSS CUSTOM PROPERTIES (tokens)
   ============================================================ */
:root {
    /* Material Design Extended Palette */
    --accent-indigo: #4f46e5;
    --accent-mint: #00bfa5;
    --accent-indigo-light: rgba(79, 70, 229, 0.15);
    --accent-mint-light: rgba(0, 191, 165, 0.15);
    --accent-indigo-gradient: linear-gradient(135deg, #4f46e5, #7c3aed);
    --accent-mint-gradient: linear-gradient(135deg, #00bfa5, #06b6d4);

    /* Surface levels (Material Design elevation) */
    --surface-0: #080b14;
    --surface-1: #0d1424;
    --surface-2: #111827;
    --surface-3: rgba(255, 255, 255, 0.06);
    --on-surface: #f0f4ff;
    --on-surface-secondary: #8892a4;
}


/* ============================================================
   2. ACTIVE NAV LINK
   ============================================================ */

/**
 * .nav-link-active — applied via JS to the current page's nav anchor.
 * Adds an animated indigo underline beneath the active item.
 */
.nav-link-active {
    color: var(--text-primary) !important;
    position: relative;
}

.nav-link-active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-indigo-gradient);
    border-radius: 2px;
}


/* ============================================================
   3. RISK PROGRESS BAR
   ============================================================ */

/**
 * Segmented horizontal bar showing proportional risk distribution.
 * Usage: <div class="risk-progress-bar">
 *          <div class="risk-progress-segment seg-high" style="width:20%"></div>
 *          <div class="risk-progress-segment seg-medium" style="width:50%"></div>
 *          <div class="risk-progress-segment seg-low" style="width:30%"></div>
 *        </div>
 */
.risk-progress-bar {
    display: flex;
    height: 8px;
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: 28px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
}

.risk-progress-segment {
    height: 100%;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.risk-progress-segment.seg-high   { background: var(--risk-high);   }
.risk-progress-segment.seg-medium { background: var(--risk-medium); }
.risk-progress-segment.seg-low    { background: var(--risk-low);    }


/* ============================================================
   4. SPLIT-SCREEN RESULTS
   ============================================================ */

/**
 * Two-column layout: sticky original text pane (left) + scrollable
 * risk cards pane (right). Collapses to single column on small viewports.
 *
 * Usage:
 * <div class="results-split">
 *   <div class="results-original-pane">
 *     <div class="results-pane-label">Original Contract</div>
 *     <pre class="results-original-text">...</pre>
 *   </div>
 *   <div class="results-risks-pane"> ... cards ... </div>
 * </div>
 */
.results-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
    margin-bottom: 28px;
}

/* Left pane — sticks to viewport while user scrolls through risks */
.results-original-pane {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: sticky;
    top: 90px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.results-original-pane::-webkit-scrollbar {
    width: 4px;
}

.results-original-pane::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* Section label pill with a coloured dot prefix */
.results-pane-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.results-pane-label::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-indigo);
    flex-shrink: 0;
}

/* Pre-formatted contract text */
.results-original-text {
    font-size: 13px;
    line-height: 1.8;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Right pane — vertically stacked risk cards */
.results-risks-pane {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Collapse to single column below 900 px */
@media (max-width: 900px) {
    .results-split {
        grid-template-columns: 1fr;
    }

    .results-original-pane {
        position: static;
        max-height: 300px;
    }
}


/* ============================================================
   5. PROCESS STEPS
   ============================================================ */

/**
 * Three-step "How it works" grid with numbered badges, icons, and a
 * subtle connecting rule between step circles.
 *
 * Usage:
 * <section class="process-section">
 *   <div class="container">
 *     <div class="process-grid">
 *       <div class="process-step">
 *         <div class="process-step-num">1</div>
 *         <span class="process-step-icon">📤</span>
 *         <h3>Upload</h3>
 *         <p>…</p>
 *       </div>
 *       … (repeat for steps 2 & 3)
 *     </div>
 *   </div>
 * </section>
 */
.process-section {
    padding: 80px 0;
    position: relative;
}

/* Subtle indigo glow overlay across the whole section */
.process-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        transparent,
        rgba(79, 70, 229, 0.03),
        transparent
    );
    pointer-events: none;
}

.process-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    position: relative;
}

/* Horizontal connector line through step-number centres */
.process-grid::before {
    content: '';
    position: absolute;
    top: 36px;                         /* vertically centred on the 52 px circle */
    left: calc(16.66% + 24px);
    right: calc(16.66% + 24px);
    height: 1px;
    background: linear-gradient(90deg, var(--accent-indigo), var(--accent-mint));
    opacity: 0.3;
    pointer-events: none;
}

.process-step {
    text-align: center;
    padding: 32px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    transition: all var(--transition);
    position: relative;
}

.process-step:hover {
    border-color: rgba(79, 70, 229, 0.3);
    transform: translateY(-4px);
    box-shadow: 0 20px 60px rgba(79, 70, 229, 0.1);
}

/* Numbered badge */
.process-step-num {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent-indigo-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    margin: 0 auto 20px;
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.35);
}

.process-step-icon {
    font-size: 28px;
    margin-bottom: 16px;
    display: block;
}

.process-step h3 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.process-step p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

@media (max-width: 768px) {
    .process-grid {
        grid-template-columns: 1fr;
    }

    .process-grid::before {
        display: none;      /* connector line irrelevant in stacked layout */
    }
}


/* ============================================================
   6. SMART INPUT TABS
   ============================================================ */

/**
 * Segmented control allowing users to switch between upload modes:
 * file upload, URL fetch, or raw text paste.
 *
 * Usage:
 * <div class="smart-input-tabs">
 *   <button class="smart-tab active" data-panel="file">📁 File</button>
 *   <button class="smart-tab" data-panel="url">🔗 URL</button>
 *   <button class="smart-tab" data-panel="text">✏️ Text</button>
 * </div>
 * <div class="smart-input-panel active" id="panel-file"> … </div>
 * <div class="smart-input-panel" id="panel-url"> … </div>
 * <div class="smart-input-panel" id="panel-text"> … </div>
 */
.smart-input-tabs {
    display: flex;
    gap: 0;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 20px;
}

.smart-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: calc(var(--radius-md) - 4px);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.smart-tab.active {
    background: var(--accent-indigo);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.smart-tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* Panel visibility toggle — JS adds/removes .active */
.smart-input-panel         { display: none;  }
.smart-input-panel.active  { display: block; }

/* URL text field */
.smart-url-input {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 15px;
    transition: border-color var(--transition);
    outline: none;
    margin-bottom: 12px;
    box-sizing: border-box;
}

.smart-url-input:focus {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.smart-url-input::placeholder { color: var(--text-muted); }

/* Multiline text paste textarea */
.smart-text-input {
    width: 100%;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    min-height: 160px;
    transition: border-color var(--transition);
    outline: none;
    box-sizing: border-box;
}

.smart-text-input:focus {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.smart-text-input::placeholder { color: var(--text-muted); }


/* ============================================================
   7. USAGE BAR (global quota indicator)
   ============================================================ */

/**
 * Card showing the user's remaining analysis quota with a thin fill bar
 * and an upgrade CTA button.
 *
 * Usage:
 * <div class="usage-bar-container">
 *   <div class="usage-bar-card">
 *     <span class="usage-bar-icon">📊</span>
 *     <div class="usage-bar-info">
 *       <div class="usage-bar-header">
 *         <span class="usage-bar-label">Analyses this month</span>
 *         <span class="usage-bar-plan">Free</span>
 *       </div>
 *       <div class="usage-bar-count">3 / 5 used</div>
 *       <div class="usage-bar-track">
 *         <div class="usage-bar-fill" style="width:60%"></div>
 *       </div>
 *     </div>
 *     <div class="usage-bar-upgrade">
 *       <a href="/pricing" class="usage-upgrade-btn">Upgrade ✨</a>
 *     </div>
 *   </div>
 * </div>
 */
.usage-bar-container {
    margin-bottom: 24px;
}

.usage-bar-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.usage-bar-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.usage-bar-info {
    flex: 1;
    min-width: 0;    /* prevent flex child from overflowing */
}

.usage-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.usage-bar-label {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Plan badge */
.usage-bar-plan {
    background: var(--accent-indigo-light);
    color: var(--accent-indigo);
    border: 1px solid rgba(79, 70, 229, 0.3);
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.usage-bar-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Track (background) */
.usage-bar-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 100px;
    overflow: hidden;
}

/* Fill — set width via inline style or JS */
.usage-bar-fill {
    height: 100%;
    background: var(--accent-indigo-gradient);
    border-radius: 100px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.usage-bar-upgrade {
    flex-shrink: 0;
}

.usage-upgrade-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    background: var(--accent-indigo-gradient);
    color: #fff;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition);
    white-space: nowrap;
}

.usage-upgrade-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4);
}


/* ============================================================
   8. MINT ACCENT UTILITIES
   ============================================================ */

/** Quick text colour helper */
.text-mint { color: var(--accent-mint); }

/** Pill badges */
.badge-mint {
    background: var(--accent-mint-light);
    border: 1px solid rgba(0, 191, 165, 0.3);
    color: var(--accent-mint);
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.badge-indigo {
    background: var(--accent-indigo-light);
    border: 1px solid rgba(79, 70, 229, 0.3);
    color: var(--accent-indigo);
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}


/* ============================================================
   9. RIPPLE EFFECT
   ============================================================ */

/**
 * CSS-only ripple on click — add class .ripple to any button/card.
 * The ::after pseudo-element expands from 0 → full size on :active,
 * then collapses back on release.
 */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    width: 120%;
    padding-bottom: 120%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    opacity: 0;
    transition: transform 0.5s, opacity 0.5s;
}

.ripple:active::after {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    transition: 0s;    /* snap in instantly, fade out on release */
}
