/* ═════════════════════════════════════════════════════════════════
 * ISPOR Recording Dashboard — refined stylesheet
 * Modern, professional, mobile-responsive.
 * Mobile-first; desktop overrides at the bottom.
 * ═════════════════════════════════════════════════════════════════ */

:root {
    --brand:        #24aadf;
    --brand-dark:   #1a7fa6;
    --brand-light:  #e6f4fa;
    --bg:           #f4f6fb;
    --card:         #ffffff;
    --border:       #e3e7ee;
    --text:         #1a2233;
    --muted:        #6b7280;
    --muted-2:      #9aa3b2;
    --success:      #10b981;
    --warn:         #f59e0b;
    --danger:       #ef4444;
    --danger-soft:  #fef2f2;

    --shadow-sm:    0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow:       0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-lg:    0 10px 30px rgba(15, 23, 42, 0.12);

    --radius-sm:    6px;
    --radius:       10px;
    --radius-lg:    14px;
}

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

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

button, input {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

a { color: inherit; }

/* ═══ Login page ═══════════════════════════════════════════════ */

.login-body {
    background: linear-gradient(135deg, #24aadf 0%, #1a7fa6 50%, #134f6e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.login-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px 28px;
    width: 100%;
    max-width: 400px;
}

.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--brand); letter-spacing: -0.01em; }
.login-logo p  { color: var(--muted); margin-top: 4px; font-size: 13px; }

.login-form .form-group { margin-bottom: 14px; }
.login-form label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.login-form input {
    width: 100%;
    padding: 11px 13px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: #fff;
    transition: border 0.15s ease, box-shadow 0.15s ease;
}
.login-form input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(36, 170, 223, 0.15);
}
.login-footer {
    text-align: center;
    margin-top: 18px;
    color: var(--muted-2);
    font-size: 11px;
}

/* ═══ Dashboard layout ═════════════════════════════════════════ */

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 6px rgba(36, 170, 223, 0.3);
}
.brand h1 {
    font-size: 16px;
    color: var(--text);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.1;
}
.brand-sub {
    font-size: 11px;
    color: var(--muted);
    font-weight: 500;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 12px 32px;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    gap: 8px;
    flex-wrap: wrap;
}

.card h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.muted     { color: var(--muted);   font-size: 13px; }

/* ═══ Server status grid ═══════════════════════════════════════ */

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

.stat {
    background: #fafbfd;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
}
.stat-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}
.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.01em;
}
.stat-unit {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    margin-left: 4px;
}
.stat-sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
}

.progress {
    height: 5px;
    background: #eef1f6;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--brand) 0%, var(--brand-dark) 100%);
    border-radius: 3px;
    width: 0%;
    transition: width 0.4s ease;
}
.progress-bar.progress-warn   { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.progress-bar.progress-danger { background: linear-gradient(90deg, #f87171, #ef4444); }

/* ═══ Multi-URL form ═══════════════════════════════════════════ */

.multi-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.multi-form-row {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 8px;
    align-items: center;
}
.multi-form-row .url-input,
.multi-form-row .name-input {
    grid-column: 2;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: #fff;
    width: 100%;
    transition: border 0.15s ease, box-shadow 0.15s ease;
}
.multi-form-row .url-input:focus,
.multi-form-row .name-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(36, 170, 223, 0.12);
}

.multi-form-row .name-input {
    margin-top: 6px;
    font-size: 12px;
    background: #fafbfd;
}

.slot-num {
    grid-row: 1 / span 2;
    grid-column: 1;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--brand-light);
    color: var(--brand-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.multi-form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.status-line {
    color: var(--muted);
    font-size: 12px;
    flex: 1;
    min-width: 100%;
    margin-top: 4px;
}

/* ═══ Buttons ══════════════════════════════════════════════════ */

.btn {
    border: none;
    background: none;
    cursor: pointer;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    transition: all 0.12s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    line-height: 1.2;
    white-space: nowrap;
    user-select: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: white;
    box-shadow: 0 1px 3px rgba(36, 170, 223, 0.3);
}
.btn-primary:hover:not(:disabled) {
    box-shadow: 0 3px 8px rgba(36, 170, 223, 0.4);
    transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-ghost {
    background: #f3f4f6;
    color: #374151;
}
.btn-ghost:hover { background: #e5e7eb; }

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
}
.btn-danger:hover { background: #fee2e2; }

.btn-small { padding: 6px 10px; font-size: 11px; }
.btn-full  { width: 100%; justify-content: center; }

/* ═══ Lists ════════════════════════════════════════════════════ */

.list { display: flex; flex-direction: column; gap: 8px; }

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #fafbfd;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    gap: 10px;
    flex-wrap: wrap;
}

.list-item-main { flex: 1; min-width: 0; }

.list-item-title {
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-item-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 4px;
    font-size: 12px;
    flex-wrap: wrap;
}

.list-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.empty-state {
    text-align: center;
    color: var(--muted-2);
    padding: 28px 12px;
    font-size: 13px;
    font-style: italic;
}

.error-msg {
    margin-top: 6px;
    font-size: 11px;
    color: var(--danger);
    background: var(--danger-soft);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    word-break: break-word;
}

/* ═══ Badges ═══════════════════════════════════════════════════ */

.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-recording { background: #fee2e2; color: #991b1b; }
.badge-recording::before { content: '● '; animation: pulse 1.4s infinite; }
.badge-starting  { background: #fef3c7; color: #92400e; }
.badge-stopping  { background: #ddd6fe; color: #6d28d9; }
.badge-done      { background: #d1fae5; color: #065f46; }
.badge-error     { background: #fee2e2; color: #991b1b; }
.badge-idle      { background: #f3f4f6; color: #555; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

/* ═══ Modal video player ═══════════════════════════════════════ */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}
.modal.hidden { display: none; }

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    max-width: 900px;
    width: 100%;
    max-height: calc(100vh - 24px);
    overflow: auto;
    z-index: 1;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 36px;
}

.modal-content video {
    width: 100%;
    max-height: 65vh;
    background: #000;
    border-radius: var(--radius-sm);
    display: block;
}

.modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #f3f4f6;
    border: none;
    font-size: 22px;
    color: var(--muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    line-height: 1;
}
.modal-close:hover { background: #e5e7eb; color: var(--text); }

/* ═══ Mobile-only / desktop-only helpers ═══════════════════════ */

.hide-mobile { display: none; }

/* ═══ DESKTOP overrides ═══════════════════════════════════════
 * Mobile-first base above. Below: 720px+ adjustments.
 * ════════════════════════════════════════════════════════════ */

@media (min-width: 720px) {
    .container       { padding: 24px; }
    .card            { padding: 22px; margin-bottom: 18px; }
    .card h2         { font-size: 16px; }

    .topbar-inner    { padding: 14px 24px; }
    .brand h1        { font-size: 18px; }

    .hide-mobile     { display: inline; }

    /* Stats grid 5 columns on desktop */
    .stats-grid      { grid-template-columns: repeat(5, 1fr); }
    .stat-value      { font-size: 20px; }

    /* Multi-form: URL + name side-by-side on desktop */
    .multi-form-row {
        grid-template-columns: 32px 2fr 1fr;
        align-items: center;
    }
    .multi-form-row .url-input  { grid-column: 2; }
    .multi-form-row .name-input { grid-column: 3; margin-top: 0; background: #fff; font-size: 13px; }
    .slot-num { grid-row: 1; grid-column: 1; width: 26px; height: 26px; font-size: 12px; }

    .status-line     { min-width: auto; margin-top: 0; }

    .list-item       { flex-wrap: nowrap; padding: 14px 16px; }
    .list-item-title { font-size: 15px; }

    .modal-content   { padding: 24px; }
}

/* On wider screens, stats grid is 5-up; on tablets bring it down */
@media (min-width: 720px) and (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}


/* ═══ Share modal & schedule form additions ══════════════════ */

.schedule-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.schedule-form .form-group {
    display: flex;
    flex-direction: column;
}

.schedule-form .form-group label {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.schedule-form .form-group input,
.schedule-form .form-group select,
#share-step1 .form-group input,
#share-step1 .form-group select,
#rename-modal .form-group input {
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: #fff;
    width: 100%;
    transition: border 0.15s ease, box-shadow 0.15s ease;
}

.schedule-form .form-group input:focus,
.schedule-form .form-group select:focus,
#share-step1 .form-group input:focus,
#share-step1 .form-group select:focus,
#rename-modal .form-group input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(36, 170, 223, 0.12);
}

.schedule-time-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

@media (min-width: 720px) {
    .schedule-time-row {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
}

/* ── Share URL display ──────────────────────────────────────── */

.share-url-box {
    display: flex;
    gap: 6px;
    align-items: center;
    background: #f3f4f6;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
}

.share-url-box input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 10px;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.share-url-box input:focus {
    outline: none;
    background: white;
    border-radius: var(--radius-sm);
}

.share-url-box button {
    flex-shrink: 0;
}

/* ── Schedule status badges ─────────────────────────────────── */

.badge-pending   { background: #dbeafe; color: #1e40af; }
.badge-running   { background: #fee2e2; color: #991b1b; }
.badge-running::before { content: '● '; animation: pulse 1.4s infinite; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #f3f4f6; color: #6b7280; }
.badge-failed    { background: #fee2e2; color: #991b1b; }

/* ── Hidden helper ─────────────────────────────────────────── */

.hidden { display: none !important; }
