/**
 * MG Uptime PRO — Dashboard Styles
 * Version: 1.0.1
 * Dark theme, monitoring dashboard
 * Brand color: 1001Web #9353AC
 */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #151d2e;
    --bg-card-hover: #1a2438;
    --bg-input: #0d1220;
    --border: #1e2a3f;
    --border-light: #263249;
    --text-primary: #e8ecf1;
    --text-secondary: #8896ab;
    --text-dim: #5a6a80;
    --accent: #9353AC;
    --accent-dim: rgba(147, 83, 172, 0.15);
    --accent-glow: rgba(147, 83, 172, 0.3);
    --accent-light: #b47cc9;
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.15);
    --green-glow: rgba(34, 197, 94, 0.3);
    --red: #ff3d57;
    --red-dim: rgba(255, 61, 87, 0.15);
    --red-glow: rgba(255, 61, 87, 0.3);
    --yellow: #ffab00;
    --yellow-dim: rgba(255, 171, 0, 0.15);
    --blue: #448aff;
    --blue-dim: rgba(68, 138, 255, 0.15);
    --purple: #9c6ade;
    --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow-green: 0 0 20px rgba(34,197,94,0.2);
    --shadow-glow-accent: 0 0 20px rgba(147,83,172,0.2);
    --shadow-glow-red: 0 0 20px rgba(255,61,87,0.2);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

a {
    color: var(--blue);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--accent-light); }

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============================================
   TOP NAVIGATION
   ============================================ */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

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

.nav-logo { flex-shrink: 0; }

.nav-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.pro-badge, .pro-badge-lg {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent), #7b3f94);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.05em;
    vertical-align: middle;
    margin-left: 2px;
}

.pro-badge-lg {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 6px;
}

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

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.87rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition);
}
.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}
.nav-link.active {
    color: var(--accent);
    background: var(--accent-dim);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.nav-site-name {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-logout {
    color: var(--text-dim);
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.nav-logout:hover {
    color: var(--red);
    background: var(--red-dim);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

/* ============================================
   STATUS HERO
   ============================================ */
.status-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    transition: all var(--transition);
}

.status-hero.up {
    border-color: rgba(0, 230, 118, 0.3);
    box-shadow: var(--shadow-glow-green);
}
.status-hero.down {
    border-color: rgba(255, 61, 87, 0.3);
    box-shadow: var(--shadow-glow-red);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
    position: relative;
}
.status-dot.up {
    background: var(--green);
    box-shadow: 0 0 12px var(--green-glow);
}
.status-dot.down {
    background: var(--red);
    box-shadow: 0 0 12px var(--red-glow);
    animation: pulse-red 1.5s infinite;
}
.status-dot.unknown { background: var(--text-dim); }

.status-dot::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid currentColor;
    opacity: 0.2;
}
.status-dot.up::after { border-color: var(--green); }
.status-dot.down::after { border-color: var(--red); }

@keyframes pulse-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-info h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.status-info p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 1px;
}

.status-meta {
    display: flex;
    gap: 8px;
}

.meta-tag {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
    background: var(--bg-primary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ============================================
   METRIC CARDS
   ============================================ */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.metric-card:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}

.card-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}
.uptime-icon { background: var(--green-dim); color: var(--green); }
.ttfb-icon { background: var(--blue-dim); color: var(--blue); }
.ssl-icon { background: var(--yellow-dim); color: var(--yellow); }
.checks-icon { background: rgba(156,106,222,0.15); color: var(--purple); }

.card-label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 4px;
}

.card-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.card-bar {
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    margin-top: 12px;
    overflow: hidden;
}

.card-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 1s ease;
}
.uptime-bar { background: linear-gradient(90deg, var(--accent), var(--accent-light)); }

.card-sparkline {
    height: 32px;
    margin-top: 8px;
}

.card-sub {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 6px;
    font-family: var(--font-mono);
}

/* ============================================
   PANELS
   ============================================ */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
}

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

.panel-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.panel-link {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--blue);
}

/* ============================================
   TIMELINE BAR (30 days)
   ============================================ */
.timeline-bar {
    display: flex;
    gap: 2px;
    height: 34px;
    align-items: stretch;
}

.timeline-day {
    flex: 1;
    border-radius: 3px;
    min-width: 4px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}
.timeline-day:hover {
    transform: scaleY(1.15);
    z-index: 2;
}
.timeline-day.up { background: var(--green); opacity: 0.8; }
.timeline-day.up:hover { opacity: 1; }
.timeline-day.down { background: var(--red); }
.timeline-day.partial { background: var(--yellow); }
.timeline-day.nodata { background: var(--border); opacity: 0.4; }

.timeline-day .tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-family: var(--font-mono);
    color: var(--text-primary);
    white-space: nowrap;
    z-index: 10;
    box-shadow: var(--shadow-md);
}
.timeline-day:hover .tooltip { display: block; }

.timeline-dates {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.72rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.timeline-legend {
    display: flex;
    gap: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}
.legend-dot.up { background: var(--green); }
.legend-dot.down { background: var(--red); }
.legend-dot.partial { background: var(--yellow); }

/* ============================================
   CHART
   ============================================ */
.chart-container {
    position: relative;
    height: 220px;
}

.chart-controls {
    display: flex;
    gap: 4px;
}

.chart-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all var(--transition);
}
.chart-btn:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
}
.chart-btn.active {
    background: var(--blue-dim);
    border-color: var(--blue);
    color: var(--blue);
}

/* ============================================
   INCIDENTS LIST (Dashboard)
   ============================================ */
.incidents-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.incident-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.incident-row:hover {
    border-color: var(--border-light);
}

.incident-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.incident-dot.resolved { background: var(--green); }
.incident-dot.ongoing { background: var(--red); animation: pulse-red 1.5s infinite; }

.incident-info {
    flex: 1;
}
.incident-cause {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}
.incident-time {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.incident-duration {
    font-size: 0.8rem;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    text-align: right;
}

.incidents-empty-dash {
    text-align: center;
    padding: 24px;
    color: var(--text-dim);
    font-size: 0.85rem;
}

/* ============================================
   INCIDENTS TABLE (Full page)
   ============================================ */
.incidents-table-wrap {
    overflow-x: auto;
}

.incidents-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.incidents-table th {
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.incidents-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.incidents-table tr:hover td {
    background: var(--bg-card-hover);
}

.incidents-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-dim);
}
.incidents-empty p {
    margin-top: 12px;
    font-size: 0.9rem;
}

/* ============================================
   SETTINGS
   ============================================ */
.page-header {
    margin-bottom: 24px;
}
.page-header h2 {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.page-header p {
    color: var(--text-secondary);
    font-size: 0.87rem;
    margin-top: 4px;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.settings-panel h3 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}
.settings-row + .settings-row {
    border-top: 1px solid var(--border);
}

.settings-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.settings-value {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
}
.settings-value.mono {
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); }
.badge-dim { background: var(--bg-primary); color: var(--text-dim); border: 1px solid var(--border); }

.settings-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid var(--border);
    font-family: var(--font-body);
}

.btn-refresh {
    background: var(--blue-dim);
    color: var(--blue);
    border-color: rgba(68,138,255,0.3);
}
.btn-refresh:hover {
    background: rgba(68,138,255,0.25);
}

.btn-logout-full {
    background: var(--red-dim);
    color: var(--red);
    border-color: rgba(255,61,87,0.3);
}
.btn-logout-full:hover {
    background: rgba(255,61,87,0.25);
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    overflow: hidden;
    position: relative;
}

.login-container {
    position: relative;
    z-index: 1;
}

.login-glow {
    position: fixed;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(147,83,172,0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 400px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
}

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

.login-logo {
    margin-bottom: 16px;
}

.logo-spin {
    animation: spin 8s linear infinite;
    transform-origin: center;
}

@keyframes spin {
    from { stroke-dashoffset: 33; }
    to { stroke-dashoffset: -99; }
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.87rem;
    margin-top: 6px;
}

.login-error {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--red-dim);
    color: var(--red);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 20px;
    border: 1px solid rgba(255,61,87,0.2);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    transition: all var(--transition);
}
.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.input-wrapper svg { color: var(--text-dim); flex-shrink: 0; }

.input-wrapper input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    padding: 12px 0;
}
.input-wrapper input::placeholder {
    color: var(--text-dim);
}

.form-hint {
    display: block;
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 6px;
}

.btn-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--accent), #7b3f94);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all var(--transition);
}
.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.75rem;
    color: var(--text-dim);
    display: flex;
    justify-content: center;
    gap: 8px;
}
.login-footer a {
    color: var(--text-dim);
}
.login-footer a:hover {
    color: var(--accent-light);
}

/* ============================================
   FOOTER
   ============================================ */
.main-footer {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-dim);
    display: flex;
    justify-content: center;
    gap: 8px;
}
.main-footer a {
    color: var(--text-dim);
}
.main-footer a:hover { color: var(--accent-light); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .cards-grid { grid-template-columns: repeat(2, 1fr); }
    .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    html { font-size: 14px; }
    .top-nav { padding: 0 12px; }
    .nav-links { display: none; }
    .nav-site-name { display: none; }
    .main-content { padding: 16px 12px 40px; }
    .cards-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .metric-card { padding: 14px; }
    .card-value { font-size: 1.3rem; }
    .status-hero { flex-direction: column; gap: 12px; align-items: flex-start; }
    .status-meta { width: 100%; justify-content: flex-start; }
    .chart-container { height: 180px; }
    .login-card { padding: 28px 20px; }
    .panel-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .timeline-legend { flex-wrap: wrap; }

    /* Mobile nav bottom bar */
    .top-nav { position: relative; }
    body::after {
        content: '';
        display: block;
        height: 60px;
    }
}
