/* ══════════════════════════════════════════
   Triton Depth Intranet
   ══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --navy: #0f3460;
    --navy-dark: #0a1f3f;
    --navy-light: #1a4a8a;
    --bg: #f0f4f8;
    --surface: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --green: #10b981;
    --green-bg: #ecfdf5;
    --green-text: #065f46;
    --amber: #f59e0b;
    --amber-bg: #fffbeb;
    --amber-text: #92400e;
    --red: #ef4444;
    --red-bg: #fef2f2;
    --red-text: #991b1b;
    --blue: #3b82f6;
    --blue-bg: #eff6ff;
    --blue-text: #1e40af;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* ── Animations ── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

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

@keyframes slideRow {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
}

.anim-up {
    animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: calc(var(--delay, 0) * 0.08s);
}

.anim-row {
    animation: slideRow 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: calc(var(--row-delay, 0) * 0.05s + 0.3s);
}

/* ── Navigation ── */
nav {
    background: linear-gradient(135deg, var(--navy-dark) 0%, #0d2847 100%);
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

nav strong {
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

nav strong::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    animation: pulse 2s ease-in-out infinite;
}

nav a {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

nav a:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

nav span {
    margin-left: auto;
    color: rgba(255,255,255,0.5);
    font-size: 13px;
}

nav form { display: inline; }

nav form button {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.6);
    padding: 5px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

nav form button:hover {
    border-color: rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.08);
}

/* ── Main ── */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

/* ── Messages ── */
.messages {
    list-style: none;
    margin-bottom: 24px;
}

.messages li {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 14px;
    background: var(--blue-bg);
    color: var(--blue-text);
    border: 1px solid #dbeafe;
    animation: fadeUp 0.4s ease both;
}

.messages li.error {
    background: var(--red-bg);
    color: var(--red-text);
    border-color: #fecaca;
}

/* ── Welcome Banner ── */
.welcome-banner {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 50%, #2563eb 100%);
    border-radius: var(--radius-lg);
    padding: 36px 40px;
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
    animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
    box-shadow: 0 4px 20px rgba(15, 52, 96, 0.25);
}

.welcome-text {
    position: relative;
    z-index: 1;
}

.welcome-banner h1 {
    font-size: 26px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.03em;
    line-height: 1.3;
}

.welcome-date {
    font-size: 15px;
    color: rgba(255,255,255,0.65);
    margin-top: 6px;
    font-weight: 400;
}

.welcome-art {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 240px;
    height: 100%;
    pointer-events: none;
}

.welcome-svg {
    width: 100%;
    height: 100%;
}

/* ── Stats Row ── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

@media (max-width: 700px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
}

.stat-card::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    border-radius: 0 4px 4px 0;
}

.stat-card--green::after { background: var(--green); }
.stat-card--amber::after { background: var(--amber); }
.stat-card--red::after   { background: var(--red); }
.stat-card--blue::after  { background: var(--blue); }

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

.stat-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon--green { background: var(--green-bg); color: var(--green); }
.stat-icon--amber { background: var(--amber-bg); color: var(--amber); }
.stat-icon--red   { background: var(--red-bg);   color: var(--red); }
.stat-icon--blue  { background: var(--blue-bg);  color: var(--blue); }

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 30px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
}

.color-green { color: var(--green); }
.color-amber { color: var(--amber); }
.color-red   { color: var(--red); }
.color-blue  { color: var(--blue); }

.stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ── Dashboard Grid ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: start;
}

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

/* ── Panels ── */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: box-shadow 0.25s;
}

.panel:hover {
    box-shadow: var(--shadow-md);
}

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

.panel-header h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
}

.panel-body {
    padding: 16px 20px;
}

.panel-body--flush {
    padding: 0;
}

/* ── Data Table ── */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead th {
    text-align: left;
    padding: 10px 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--border-light);
}

.table tbody td {
    padding: 13px 20px;
    font-size: 14px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

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

.table tbody tr {
    transition: background 0.15s;
}

.table tbody tr:hover {
    background: #f8fafc;
}

.td-name {
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.buoy-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.buoy-dot--operational { background: var(--green); box-shadow: 0 0 6px rgba(16, 185, 129, 0.4); }
.buoy-dot--warning     { background: var(--amber); box-shadow: 0 0 6px rgba(245, 158, 11, 0.4); }
.buoy-dot--critical    { background: var(--red); box-shadow: 0 0 6px rgba(239, 68, 68, 0.4); animation: pulse 1.5s ease-in-out infinite; }

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

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.4;
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.badge--operational {
    background: var(--green-bg);
    color: var(--green-text);
}
.badge--operational::before { background: var(--green); }

.badge--warning {
    background: var(--amber-bg);
    color: var(--amber-text);
}
.badge--warning::before { background: var(--amber); }

.badge--critical {
    background: var(--red-bg);
    color: var(--red-text);
}
.badge--critical::before { background: var(--red); animation: pulse 1.5s ease-in-out infinite; }

/* ── Battery Bar ── */
.battery {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 120px;
}

.battery-track {
    flex: 1;
    height: 7px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}

.battery-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.battery-fill--good { background: linear-gradient(90deg, #34d399, var(--green)); }
.battery-fill--low  { background: linear-gradient(90deg, #fbbf24, var(--amber)); }
.battery-fill--crit { background: linear-gradient(90deg, #f87171, var(--red)); }

.battery-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 32px;
    text-align: right;
}

/* ── Sidebar ── */
.sidebar {
    position: sticky;
    top: 72px;
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── Quick Links ── */
.link-group {
    margin-bottom: 16px;
}

.link-group:last-child {
    margin-bottom: 0;
}

.link-group-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

.link-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 8px;
    border-radius: var(--radius-sm);
    margin: 0 -8px;
    transition: background 0.15s;
}

.link-row:hover {
    background: var(--border-light);
}

.link-anchor {
    color: var(--navy);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: color 0.15s;
}

.link-anchor:hover {
    color: var(--blue);
}

.link-anchor::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--blue);
    margin-right: 8px;
    vertical-align: middle;
    opacity: 0.4;
}

.link-controls {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
}

.link-row:hover .link-controls {
    opacity: 1;
}

.ctrl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
    transition: all 0.15s;
}

.ctrl-btn:hover {
    background: var(--surface);
    color: var(--text);
}

.ctrl-btn--del:hover {
    background: var(--red-bg);
    color: var(--red-text);
}

/* ── Activity Feed ── */
.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 8px;
    border-radius: var(--radius-sm);
    margin: 0 -8px;
    transition: background 0.15s;
}

.activity-item:hover {
    background: var(--border-light);
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}

.activity-dot--green { background: var(--green); box-shadow: 0 0 6px rgba(16, 185, 129, 0.3); }
.activity-dot--amber { background: var(--amber); box-shadow: 0 0 6px rgba(245, 158, 11, 0.3); }
.activity-dot--red   { background: var(--red); box-shadow: 0 0 6px rgba(239, 68, 68, 0.3); }

.activity-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.activity-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.35;
}

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

/* ── Empty State ── */
.empty {
    text-align: center;
    padding: 24px 0 8px;
}

.empty p {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 12px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 16px;
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
    line-height: 1.4;
}

.btn:hover {
    background: var(--navy-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(15, 52, 96, 0.25);
}

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

.btn--danger {
    background: var(--red);
}
.btn--danger:hover {
    background: #dc2626;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* ── Forms ── */
form p { margin-bottom: 16px; }

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

form input[type="text"],
form input[type="password"],
form input[type="email"],
form input[type="url"],
form input[type="number"],
form select {
    width: 100%;
    max-width: 400px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}

form input:focus,
form select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

form button[type="submit"] {
    background: var(--navy);
    color: #fff;
    border: none;
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    transition: all 0.2s;
}

form button[type="submit"]:hover {
    background: var(--navy-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(15, 52, 96, 0.25);
}

/* ── Link Management Form ── */
.link-form .form-row {
    margin-bottom: 20px;
}

.link-form label {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 13px;
}

.link-form input,
.link-form select {
    width: 100%;
    max-width: 420px;
}

.link-form small {
    display: block;
    color: var(--text-muted);
    margin-top: 4px;
    font-size: 12px;
}

.link-form .field-error {
    display: block;
    color: var(--red);
    font-size: 13px;
    margin-top: 4px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
}

.form-actions a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
}

.form-actions a:hover {
    color: var(--text);
}

/* ── Generic heading reset ── */
h1 { color: var(--text); }
h2 { margin: 0; }

/* ── Page Header (used by non-dashboard pages) ── */
.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.page-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 400;
}

/* ── Status Reason ── */
.status-reason {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 3px;
    line-height: 1.3;
}

/* ── API Error Banner ── */
.api-error-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    margin-bottom: 20px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 10px;
    color: #ef4444;
    font-size: 14px;
    font-weight: 500;
}
