/**
 * FalexAdmin - Master Stylesheet
 * Falex Systems Clean White Design System & Typography
 */

@font-face {
    font-family: 'Graphik';
    src: url('graphik/Graphik-Regular.woff2') format('woff2'),
         url('graphik/Graphik-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Graphik';
    src: url('graphik/Graphik-Medium.woff2') format('woff2'),
         url('graphik/Graphik-Medium.woff') format('woff');
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: 'Graphik';
    src: url('graphik/Graphik-Semibold.woff2') format('woff2'),
         url('graphik/Graphik-Semibold.woff') format('woff');
    font-weight: 600;
    font-style: normal;
}

:root {
    --bg-body: #ffffff;
    --bg-surface: #f9f9f9;
    --bg-card: #ffffff;
    --bg-terminal: #0d1117;
    --bg-terminal-header: #161b22;
    --text-primary: #111111;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --text-inverse: #ffffff;
    --border-light: #e5e5e5;
    --border-dark: #333333;
    --border-terminal: #30363d;
    --color-green: #090;
    --color-green-soft: #10b981;
    --color-red: #c00;
    --color-red-soft: #ef4444;
    --color-blue: #0066cc;
    --color-amber: #d97706;
    --font-stack: 'Graphik', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    --radius-sm: 2px;
    --radius-md: 4px;
    --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-stack);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* Top Navigation Bar */
.top-nav {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    height: 70px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.brand-logo-img {
    height: 38px;
    width: auto;
    max-width: 180px;
    display: block;
}

.app-tag {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    background: #f0f0f0;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-item {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    cursor: pointer;
    background: transparent;
    border: none;
    font-family: inherit;
}

.nav-item:hover {
    color: var(--text-primary);
    background: #f4f4f4;
}

.nav-item.active {
    color: var(--text-primary);
    font-weight: 600;
    background: #ebebeb;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    font-family: var(--font-stack);
    text-decoration: none;
    user-select: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--text-primary);
    color: var(--text-inverse);
    border-color: var(--text-primary);
}

.btn-primary:hover {
    background: #000000;
    border-color: #000000;
}

.btn-outline {
    background: transparent;
    border-color: var(--border-light);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--text-primary);
    background: #fafafa;
}

.btn-danger {
    background: transparent;
    border-color: #fca5a5;
    color: var(--color-red);
}

.btn-danger:hover {
    background: #fef2f2;
    border-color: var(--color-red);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Metrics Cards (matching finance style) */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    box-shadow: var(--shadow-subtle);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.metric-card:hover {
    box-shadow: var(--shadow-hover);
}

.metric-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    font-family: var(--font-stack);
    line-height: 1.1;
}

/* Broadcast Console Card */
.broadcast-card {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-subtle);
}

.broadcast-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.broadcast-heading {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.badge-mode {
    font-size: 11px;
    font-weight: 600;
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.command-bar {
    display: flex;
    gap: 10px;
}

.cmd-input {
    flex: 1;
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 11px 16px;
    font-family: var(--font-mono);
    font-size: 13.5px;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
}

.cmd-input:focus {
    border-color: #111111;
}

/* Preset Chips */
.presets-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.presets-tag {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
}

.preset-btn {
    background: #f9f9f9;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.preset-btn:hover {
    color: #000;
    border-color: #111;
    background: #ffffff;
}

/* Target Selection */
.target-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #f0f0f0;
    font-size: 12.5px;
    color: var(--text-secondary);
}

.target-chips {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* Terminal Grid */
.terminal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(560px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* Clean White Unix Terminal */
.terminal-card {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-subtle);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.2s ease;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.terminal-card:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow-hover);
}

.terminal-card.expanded {
    grid-column: 1 / -1;
}

/* Light Terminal Window Header */
.terminal-card-header {
    background: #f8fafc;
    border-bottom: 1px solid var(--border-light);
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.window-dots {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-right: 12px;
}

.window-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.window-dot.dot-red { background: #ff5f56; }
.window-dot.dot-yellow { background: #ffbd2e; }
.window-dot.dot-green { background: #27c93f; }

.server-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.server-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.server-endpoint {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: inherit;
}

.terminal-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-term-tool {
    background: #ffffff;
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-stack);
}

.btn-term-tool:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.btn-term-danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: var(--color-red);
}

.btn-term-danger:hover {
    background: #fee2e2;
}

/* Pure White Terminal Screen Viewport */
.terminal-screen {
    background: #ffffff;
    color: #0f172a;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13px;
    line-height: 1.6;
    padding: 16px;
    min-height: 320px;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    cursor: text;
    position: relative;
}

.terminal-card.expanded .terminal-screen {
    max-height: 750px;
    min-height: 520px;
}

.terminal-screen::-webkit-scrollbar {
    width: 7px;
}
.terminal-screen::-webkit-scrollbar-track {
    background: #ffffff;
}
.terminal-screen::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}
.terminal-screen::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

.term-banner {
    color: #64748b;
    border-bottom: 1px dashed var(--border-light);
    padding-bottom: 6px;
    margin-bottom: 12px;
    font-size: 12px;
}

.term-os-info {
    color: #64748b;
    font-size: 11.5px;
    margin-bottom: 8px;
}

/* Authentic Terminal Buffer & Monospace Typography */
.term-buffer {
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.55;
}

.term-line {
    margin-bottom: 3px;
    line-height: 1.55;
}

.term-cmd-line {
    margin-top: 6px;
    margin-bottom: 3px;
    line-height: 1.55;
}

.term-cmd-text {
    color: #0f172a;
    font-weight: 700;
}

/* Prompt Line - Pure Unix Style, Zero Form Appearance */
.term-prompt-row {
    display: flex;
    align-items: center;
    margin-top: 6px;
    line-height: 1.55;
}

.term-prompt-row.hidden {
    display: none !important;
}

.prompt-prefix {
    color: #059669; /* Crisp Forest Green */
    font-weight: 700;
    margin-right: 6px;
    user-select: none;
    white-space: nowrap;
    font-family: inherit;
}

.prompt-path {
    color: #2563eb; /* Deep Slate Blue */
}

.prompt-char {
    color: #475569;
}

.term-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
}

.term-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #0f172a;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 13px;
    font-weight: 600;
    padding: 0;
    margin: 0;
    caret-color: #059669;
    line-height: 1.55;
}

.term-input::placeholder {
    color: transparent; /* Absolutely no ugly placeholder text */
}

.term-input:focus {
    outline: none;
}

/* Clean Running Status Indicator (Replaces prompt while job is active) */
.term-running-bar {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 5px 11px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: #334155;
    font-family: inherit;
    font-weight: 500;
}

.term-running-bar.hidden {
    display: none !important;
}

.term-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid #cbd5e1;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: term-spin 0.75s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}

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

/* Terminal Exit / Completion Meta Badges */
.term-meta {
    display: inline-block;
    font-size: 12px;
    font-family: inherit;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
    margin-bottom: 4px;
}

.term-meta-success {
    color: #047857;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.term-meta-warning {
    color: #b45309;
    background: #fffbeb;
    border: 1px solid #fde68a;
}

.term-meta-error {
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.term-success {
    color: #059669;
    font-weight: 600;
}

.term-error {
    color: #dc2626;
    font-weight: 600;
}

.term-warning {
    color: #d97706;
    font-weight: 600;
}

/* Tables */
.table-card {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-subtle);
}

.table-toolbar {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
}

.search-input {
    padding: 8px 14px;
    font-size: 13px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    outline: none;
    width: 300px;
    font-family: inherit;
}

.search-input:focus {
    border-color: #111;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.table th {
    background: #fafafa;
    text-align: left;
    padding: 12px 18px;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}

.table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background: #fafafa;
}

/* Modal Dialog */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.modal-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-heading {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--border-light);
    background: #fafafa;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Form Styles */
.form-field {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 13.5px;
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
}

.form-input:focus {
    border-color: #111;
}

textarea.form-input {
    font-family: var(--font-mono);
    font-size: 12px;
    resize: vertical;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-hint {
    font-size: 11.5px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Login Gateway Screen */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9f9f9;
    padding: 24px;
}

.auth-box {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    width: 100%;
    max-width: 400px;
    padding: 32px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.auth-logo-wrap {
    text-align: center;
    margin-bottom: 24px;
}

.auth-logo-img {
    height: 42px;
    width: auto;
    max-width: 200px;
    margin: 0 auto 10px;
    display: block;
}

.auth-title {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.auth-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Alerts */
.alert-box {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    margin-bottom: 16px;
    line-height: 1.45;
}

.alert-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--color-red);
}

.alert-success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: var(--color-green);
}

.alert-diagnostic {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #334155;
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 12px;
    margin-top: 10px;
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
}

/* Utilities */
.hidden { display: none !important; }
.text-mono { font-family: var(--font-mono); }
.text-secondary { color: var(--text-secondary); }

@media (max-width: 768px) {
    .terminal-grid {
        grid-template-columns: 1fr;
    }
    .form-grid-2 {
        grid-template-columns: 1fr;
    }
    .nav-container {
        height: auto;
        padding: 14px 20px;
        flex-direction: column;
        gap: 12px;
    }
    .command-bar {
        flex-direction: column;
    }
}
