/* --------------------------------------------------------------------------
   PulseTrack Dashboard - Modern, Responsive CSS
   -------------------------------------------------------------------------- */

:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-subtle: #f1f5f9;
    --border-color: #e2e8f0;
    --border-light: #edf2f7;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --color-up: #10b981;
    --color-up-bg: #ecfdf5;
    --color-up-border: #a7f3d0;
    
    --color-degraded: #f59e0b;
    --color-degraded-bg: #fffbeb;
    --color-degraded-border: #fde68a;
    
    --color-down: #ef4444;
    --color-down-bg: #fef2f2;
    --color-down-border: #fecaca;
    
    --color-unknown: #64748b;
    --color-unknown-bg: #f8fafc;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --radius: 10px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --------------------------------------------------------------------------
   Navbar
   -------------------------------------------------------------------------- */
.navbar {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

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

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

.brand-pulse {
    width: 12px;
    height: 12px;
    background-color: var(--color-up);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.brand-title {
    font-size: 19px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.brand-subtitle {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-subtle);
    padding: 2px 8px;
    border-radius: 6px;
    margin-left: 6px;
}

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

.nav-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary);
    background-color: #eff6ff;
}

.nav-divider {
    width: 1px;
    height: 24px;
    background-color: var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-subtle);
    padding: 4px 10px;
    border-radius: 20px;
}

.btn-logout {
    font-size: 13px;
    color: #dc2626;
    text-decoration: none;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
}

.btn-logout:hover {
    background: var(--color-down-bg);
}

/* --------------------------------------------------------------------------
   Main Container
   -------------------------------------------------------------------------- */
.main-container {
    max-width: 1280px;
    width: 100%;
    margin: 28px auto;
    padding: 0 24px;
    flex: 1;
}

/* Flash Messages */
.flash-container {
    margin-bottom: 20px;
}

.flash-alert {
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 10px;
}

.flash-info {
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

/* --------------------------------------------------------------------------
   Hero Status Banner
   -------------------------------------------------------------------------- */
.hero-status-banner {
    border-radius: var(--radius);
    padding: 24px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.hero-status-banner.status-up {
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
    border: 1px solid var(--color-up-border);
}

.hero-status-banner.status-degraded {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid var(--color-degraded-border);
}

.hero-status-banner.status-down {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border: 1px solid var(--color-down-border);
}

.status-indicator-wrapper {
    position: relative;
    width: 24px;
    height: 24px;
    margin-right: 18px;
    flex-shrink: 0;
}

.status-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    position: absolute;
    top: 4px;
    left: 4px;
}

.status-up .status-dot { background-color: var(--color-up); }
.status-degraded .status-dot { background-color: var(--color-degraded); }
.status-down .status-dot { background-color: var(--color-down); }

.status-pulse-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    animation: ping 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.status-up .status-pulse-ring { background-color: rgba(16, 185, 129, 0.4); }
.status-degraded .status-pulse-ring { background-color: rgba(245, 158, 11, 0.4); }
.status-down .status-pulse-ring { background-color: rgba(239, 68, 68, 0.4); }

@keyframes ping {
    75%, 100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

.status-details {
    flex: 1;
}

.hero-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.status-up .hero-title { color: #065f46; }
.status-degraded .hero-title { color: #92400e; }
.status-down .hero-title { color: #991b1b; }

.hero-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

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

.auto-refresh-control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-select-sm {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: #ffffff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   Metrics Grid
   -------------------------------------------------------------------------- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}

.metric-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-val {
    font-size: 32px;
    font-weight: 700;
    margin: 4px 0;
    letter-spacing: -1px;
}

.metric-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.text-success { color: var(--color-up); }
.text-warning { color: var(--color-degraded); }
.text-danger { color: var(--color-down); }

/* --------------------------------------------------------------------------
   Section Headers
   -------------------------------------------------------------------------- */
.section-header {
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.section-tagline {
    font-size: 13px;
    color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Services Grid & Cards
   -------------------------------------------------------------------------- */
.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.service-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.service-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.status-border-up { border-top: 4px solid var(--color-up); }
.status-border-degraded { border-top: 4px solid var(--color-degraded); }
.status-border-down { border-top: 4px solid var(--color-down); }
.status-border-unknown { border-top: 4px solid var(--color-unknown); }

.service-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.service-category-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary);
    background-color: #eff6ff;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 6px;
}

.service-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.status-pill-up {
    background-color: var(--color-up-bg);
    color: #065f46;
    border: 1px solid var(--color-up-border);
}

.status-pill-degraded {
    background-color: var(--color-degraded-bg);
    color: #92400e;
    border: 1px solid var(--color-degraded-border);
}

.status-pill-down {
    background-color: var(--color-down-bg);
    color: #991b1b;
    border: 1px solid var(--color-down-border);
}

.status-pill-unknown {
    background-color: var(--color-unknown-bg);
    color: var(--color-unknown);
    border: 1px solid var(--border-color);
}

.service-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    background: var(--bg-main);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 14px;
}

.service-metric-item {
    display: flex;
    flex-direction: column;
}

.sm-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
}

.sm-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.uptime-bar-wrapper {
    height: 6px;
    background-color: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 14px;
}

.uptime-bar-fill {
    height: 100%;
    background-color: var(--color-up);
    border-radius: 9999px;
    transition: width 0.4s ease;
}

.service-alert-banner {
    background-color: var(--color-down-bg);
    border: 1px solid var(--color-down-border);
    color: #991b1b;
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.service-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 14px;
    border-top: 1px solid var(--border-light);
}

.last-checked {
    font-size: 11px;
    color: var(--text-muted);
}

.card-btn-group {
    display: flex;
    gap: 8px;
}

.btn-card-action {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-card-action:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
    border-color: #cbd5e1;
}

.btn-trigger-check {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.btn-trigger-check:hover {
    background: var(--primary-hover);
    color: #ffffff;
}

.btn-spinner {
    display: none;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* --------------------------------------------------------------------------
   Cards, Tables, and Charts
   -------------------------------------------------------------------------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.chart-header h3 {
    font-size: 17px;
    font-weight: 700;
}

.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

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

.card-header-flex h3 {
    font-size: 16px;
    font-weight: 700;
}

.card-header-link {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.card-header-link:hover {
    text-decoration: underline;
}

.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #065f46;
    background: #ecfdf5;
    padding: 3px 10px;
    border-radius: 9999px;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--color-up);
    border-radius: 50%;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.split-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .split-section {
        grid-template-columns: 1fr;
    }
}

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.data-table th {
    padding: 10px 12px;
    background: var(--bg-main);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}

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

.data-table tr:hover td {
    background-color: #fafbfc;
}

.badge-status-sm {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-up { background: var(--color-up-bg); color: #065f46; border: 1px solid var(--color-up-border); }
.badge-degraded { background: var(--color-degraded-bg); color: #92400e; border: 1px solid var(--color-degraded-border); }
.badge-down { background: var(--color-down-bg); color: #991b1b; border: 1px solid var(--color-down-border); }

.badge-active-incident {
    background: var(--color-down-bg);
    color: #991b1b;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
}

.table-empty {
    text-align: center;
    padding: 24px !important;
    color: var(--text-muted);
}

.truncate {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --------------------------------------------------------------------------
   Settings & Incidents Pages
   -------------------------------------------------------------------------- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

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

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

.card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.registered-services-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.registered-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-main);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.badge-item-cat {
    font-size: 11px;
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    color: #475569;
}

.item-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

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

.settings-table tr {
    border-bottom: 1px solid var(--border-light);
}

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

.settings-table td {
    padding: 12px 0;
    vertical-align: middle;
}

.settings-table td:first-child {
    width: 48%;
    color: var(--text-secondary);
    font-weight: 500;
    padding-right: 12px;
}

.settings-table td:last-child {
    width: 52%;
    text-align: right;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.settings-table code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    background: var(--bg-subtle);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    word-break: break-all;
    white-space: normal;
    display: inline-block;
    text-align: left;
    max-width: 100%;
}

.btn-copy-sm {
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-copy-sm:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.incident-summary-text {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.incident-details-raw {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    background: var(--bg-main);
    padding: 8px;
    border-radius: 6px;
    white-space: pre-wrap;
    max-height: 120px;
    overflow-y: auto;
}

/* --------------------------------------------------------------------------
   Login View
   -------------------------------------------------------------------------- */
.login-wrapper {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 24px;
}

.login-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.login-header p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

.login-error-alert {
    background: var(--color-down-bg);
    border: 1px solid var(--color-down-border);
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group {
    margin-bottom: 18px;
}

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

.form-input {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 14px;
    transition: border-color 0.15s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    border: none;
    padding: 11px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

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

.btn-secondary {
    background-color: #ffffff;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.btn-secondary:hover {
    background-color: var(--bg-subtle);
    color: var(--text-primary);
}

.btn-block {
    width: 100%;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    border-top: 1px solid var(--border-light);
    padding-top: 16px;
}

.login-hint {
    font-size: 12px;
    color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Modal Backdrop & Dialog
   -------------------------------------------------------------------------- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-card {
    background: #ffffff;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.footer {
    border-top: 1px solid var(--border-color);
    background: #ffffff;
    padding: 20px 0;
    margin-top: auto;
}

.footer-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}
