/* === Design Tokens === */
:root {
    --color-primary: #F10358;
    --color-dark: #000000;
    --color-white: #ffffff;
    --color-off-white: #fcfdff;
    --color-text: #2d2d2d;
    --color-text-muted: #666572;
    --color-light-gray: #f6f6f6;
    --color-border: #F0F0F0;
    --color-danger: #e74c3c;
    --nav-height: 50px;
}

/* === Alpine.js === */
[x-cloak] { display: none !important; }

/* === Reset === */
*, *::before, *::after {
    box-sizing: border-box;
    font-family: "Montserrat", sans-serif;
}
html, body { height: 100%; margin: 0; padding: 0; }
body { background: var(--color-off-white); color: var(--color-text); }
a { text-decoration: none; }

/* === Brand === */
.brand { font-size: 1.2rem; font-weight: 700; letter-spacing: -1px; }
.brand-ela { color: var(--color-white); }
.brand-connect { color: var(--color-primary); }

/* === Navbar === */
.navbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    height: var(--nav-height);
    background: var(--color-dark);
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 20px;
}

/* === Tabs === */
.tabs { display: flex; gap: 0.5rem; margin-right: 0.5rem; }
.tab {
    font-family: "Montserrat", sans-serif;
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    background: var(--color-light-gray); color: var(--color-text);
    padding: 10px 15px; border-radius: 5px;
    border: 1px solid var(--color-border);
    cursor: pointer; user-select: none;
    text-decoration: none; display: inline-block;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tab:hover {
    background: var(--color-primary); border-color: var(--color-primary); color: var(--color-light-gray);
}
.tab.active {
    background: var(--color-primary); border-color: var(--color-primary); color: var(--color-white);
}

/* === Layout === */
.container {
    max-width: 1100px; margin: 0 auto;
    padding: calc(var(--nav-height) + 1.5rem) 1rem 2.5rem;
}

/* === Cards === */
.card {
    background: var(--color-white);
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

/* === Tables === */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--color-border); }
th { color: var(--color-text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }

/* === Buttons === */
.btn {
    font-family: "Montserrat", sans-serif;
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    padding: 10px 15px; border-radius: 5px;
    border: 1px solid var(--color-border);
    background: var(--color-light-gray); color: var(--color-text);
    cursor: pointer; user-select: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-white); }
.btn-primary {
    background: var(--color-primary); border-color: var(--color-primary); color: var(--color-white);
}
.btn-primary:hover {
    background: rgba(234, 232, 242, 0.2); border-color: var(--color-dark); color: var(--color-dark);
}
.btn-danger { background: var(--color-danger); border-color: var(--color-danger); color: var(--color-white); }
.btn-danger:hover { opacity: 0.85; }
.btn-sm { padding: 6px 10px; font-size: 11px; }
.btn-disabled { opacity: 0.4; cursor: not-allowed; }
.btn-disabled:hover { background: var(--color-light-gray); border-color: var(--color-border); color: var(--color-text); }

/* === Section Title === */
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.section-title h2 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.5px; }

/* === Peers Header === */
.peers-header {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 1rem;
}
.peers-header h2 {
    flex: 1; font-size: 1.1rem; font-weight: 700; letter-spacing: -0.5px; margin: 0;
}
.peers-header h2 .mono { font-weight: 400; color: var(--color-text-muted); font-size: 0.85rem; }

/* === Forms === */
.form-row { display: flex; gap: 0.5rem; margin-bottom: 0.8rem; flex-wrap: wrap; }
.form-row input, .form-row select {
    font-family: "Montserrat", sans-serif;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 5px;
    font-size: 0.85rem;
    color: var(--color-text);
    background: var(--color-white);
}
.form-row input { flex: 1; min-width: 120px; }
.form-row input:focus, .form-row select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(241, 3, 88, 0.1);
}

/* === Interface Form Layout === */
.iface-form-grid { display: flex; flex-direction: column; gap: 0.5rem; }
.iface-form-row1 {
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
}
.iface-form-row1 input { flex: 1; min-width: 120px; }
.iface-form-row2 { display: flex; align-items: center; }

/* === IP Group === */
.ip-group { display: inline-flex; align-items: center; gap: 2px; font-family: monospace; font-size: 0.9rem; }
.ip-group input[type="number"] {
    width: 50px; padding: 0.4rem 0.3rem;
    border: 1px solid var(--color-border); border-radius: 5px;
    font-size: 0.85rem; text-align: center; -moz-appearance: textfield;
}
.ip-group input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
.ip-group select {
    min-width: 50px; padding: 0.4rem 0.2rem;
    border: 1px solid var(--color-border); border-radius: 5px;
    font-size: 0.85rem; font-family: monospace;
}
.ip-group .dot { padding: 0 1px; }

/* === Utility === */
.hidden { display: none !important; }
.mono { font-family: monospace; font-size: 0.8rem; }
.badge {
    display: inline-block; padding: 0.15rem 0.5rem;
    border-radius: 10px; font-size: 0.75rem; font-weight: 600;
    background: var(--color-light-gray); color: var(--color-text-muted);
}
.copyable { cursor: pointer; }
.copyable:hover { color: var(--color-primary); }
.peers-toggle { cursor: pointer; color: var(--color-primary); font-size: 0.85rem; font-weight: 600; }
.badge-you {
    background: var(--color-primary); color: var(--color-white);
    font-size: 0.65rem; padding: 0.1rem 0.4rem; vertical-align: middle;
}

/* === Severity Badges === */
.severity-info { background: #e0e0e0; color: #555; }
.severity-warning { background: #fff3cd; color: #856404; }
.severity-error { background: #f8d7da; color: #721c24; }
.severity-critical { background: var(--color-danger); color: var(--color-white); }

.restricted-banner {
    background: #fff3cd; border: 1px solid #ffc107; border-radius: 6px;
    padding: 0.75rem 1rem; margin-bottom: 1rem;
    font-size: 0.85rem; color: #856404; font-weight: 600;
}

/* === Modals === */
body.modal-open { overflow: hidden; }
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}
.modal-body {
    background: var(--color-white); border-radius: 6px;
    padding: 1.5rem; max-width: 600px; width: 90%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.modal-body h3 { margin-bottom: 1rem; font-size: 1rem; font-weight: 700; }
.modal-body textarea {
    width: 100%; height: 220px;
    font-family: monospace; font-size: 0.85rem;
    border: 1px solid var(--color-border); border-radius: 5px;
    padding: 0.8rem; resize: vertical; color: var(--color-text);
}
.modal-body .btn-row { display: flex; gap: 0.5rem; margin-top: 0.8rem; justify-content: flex-end; }
.modal-form { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.modal-form label { font-size: 0.85rem; font-weight: 600; color: var(--color-text-muted); }
.modal-form input, .modal-form select {
    font-family: "Montserrat", sans-serif;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--color-border); border-radius: 5px;
    font-size: 0.85rem; color: var(--color-text);
    background: var(--color-white);
}
.modal-form input:focus, .modal-form select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(241, 3, 88, 0.1);
}

/* === Status Output === */
#status-text {
    font-family: monospace; font-size: 0.85rem;
    background: var(--color-light-gray);
    border: 1px solid var(--color-border); border-radius: 5px;
    padding: 1rem; margin: 0;
    max-height: 400px; overflow-y: auto;
    white-space: pre-wrap; word-break: break-all;
}

/* === Login Page === */
.login-page {
    background: radial-gradient(94% 58.3% at 50.3% 82.6%, #2a2541 0%, rgb(17, 16, 19) 100%);
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
}
.login-card {
    background: var(--color-white); border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    padding: 3rem 2.5rem; max-width: 400px; width: 90%;
    text-align: center;
}
.login-brand {
    font-size: 2rem; font-weight: 700; letter-spacing: -2px;
    margin: 0 0 1rem;
}
.login-subtitle {
    font-size: 0.9rem; color: var(--color-text-muted);
    margin: 0 0 2rem; line-height: 1.5;
}
.login-btn {
    display: inline-block; font-size: 14px; padding: 12px 32px;
    text-decoration: none;
}

/* === Navbar Auth === */
.navbar-right { display: flex; align-items: center; gap: 0.75rem; }
.navbar-user {
    font-size: 0.75rem; color: rgba(255,255,255,0.6); font-weight: 500;
    max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.navbar-role {
    display: inline-block; padding: 0.1rem 0.4rem;
    border-radius: 3px; font-size: 0.6rem; font-weight: 700;
    text-transform: uppercase; vertical-align: middle;
    background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.7);
}
.navbar-role.role-superuser { background: var(--color-primary); color: var(--color-white); }
.navbar-role.role-admin { background: #e67e22; color: var(--color-white); }

/* === Statusbar === */
.statusbar {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--color-dark);
    color: rgba(255,255,255,0.6);
    font-size: 0.75rem; font-weight: 500;
    padding: 0.3rem 2rem;
    display: flex; justify-content: space-between;
}
.statusbar .brand-ela { color: rgba(255,255,255,0.6); }
.statusbar .brand-connect { color: var(--color-primary); }

/* === Table Scroll Wrapper === */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* === Tablet (769–999px) === */
@media (min-width: 769px) and (max-width: 999px) {
    .container { padding-left: 0.75rem; padding-right: 0.75rem; }
    .card { padding: 1rem; }

    .table-wrap table { min-width: 600px; }

    .navbar { padding: 8px 12px; }
    .tab { padding: 8px 12px; }
    .navbar-user { max-width: 140px; }
}

/* === Hamburger (hidden on desktop, shown on mobile) === */
.hamburger {
    display: none;
    background: none; border: none; cursor: pointer;
    padding: 6px; margin-left: auto;
}
.hamburger span {
    display: block; width: 22px; height: 2px;
    background: var(--color-white); border-radius: 2px;
    margin: 4px 0; transition: transform 0.2s, opacity 0.2s;
}
.hamburger.active span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* === Menu Backdrop === */
.menu-backdrop {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); z-index: 40;
}

/* === Mobile (≤768px) === */
@media (max-width: 768px) {
    /* Hamburger visible */
    .hamburger { display: block; }

    /* Navbar: single-line, no wrap */
    .navbar {
        padding: 6px 10px;
    }
    .brand { font-size: 1rem; }

    /* Navbar menu: hidden by default, dropdown when open */
    .navbar-right {
        display: none;
        position: absolute; top: var(--nav-height); left: 0; right: 0;
        background: var(--color-dark);
        flex-direction: column; align-items: stretch;
        padding: 0.5rem 1rem 1rem;
        gap: 0.4rem;
        z-index: 51;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }
    .navbar-right.open { display: flex; }

    /* Tabs: stack vertically in dropdown */
    .tabs { flex-direction: column; gap: 0.3rem; margin-right: 0; }
    .tab {
        padding: 10px 12px; font-size: 11px;
        text-align: left; width: 100%;
        border-radius: 4px;
    }

    /* Auth info in dropdown */
    .navbar-user {
        display: block; font-size: 0.75rem;
        max-width: none; padding-top: 0.5rem;
        border-top: 1px solid rgba(255,255,255,0.1);
    }
    .navbar-role { display: inline-block; }
    #navbar-logout { padding: 8px 12px; font-size: 11px; width: 100%; text-align: left; }

    /* Container */
    .container {
        padding: calc(var(--nav-height) + 0.75rem) 0.5rem 2rem;
    }

    /* Cards */
    .card { padding: 0.75rem; }
    .section-title { flex-wrap: wrap; gap: 0.5rem; }
    .section-title h2 { font-size: 0.95rem; }
    .peers-header { flex-wrap: wrap; gap: 0.4rem; }
    .peers-header h2 { font-size: 0.95rem; }

    /* Tables → card layout */
    .table-wrap { overflow-x: visible; }
    .table-wrap table { min-width: 0; }
    table { font-size: 0.85rem; }
    thead { display: none; }
    tbody tr {
        display: block;
        border: 1px solid var(--color-border);
        border-radius: 6px;
        margin-bottom: 0.75rem;
        padding: 0.5rem 0;
        background: var(--color-white);
    }
    tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.35rem 0.75rem;
        border-bottom: none;
        text-align: right;
    }
    tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.75rem;
        color: var(--color-text-muted);
        text-transform: uppercase;
        text-align: left;
        margin-right: 1rem;
        flex-shrink: 0;
    }
    /* Actions row: no label, Peers left / rest right */
    tbody td[data-label=""]::before { display: none; }
    tbody td[data-label=""] {
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 0.3rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--color-border);
    }
    tbody td[data-label=""] .btn-peers {
        margin-right: auto;
    }
    .btn-sm { padding: 5px 8px; font-size: 10px; }

    /* Forms */
    .form-row { flex-direction: column; }
    .form-row input { min-width: 0; width: 100%; flex: none; }
    .form-row select { width: 100%; }
    .ip-group {
        display: flex; flex-wrap: wrap;
        width: 100%; gap: 2px;
    }
    .ip-group select { flex: 1; min-width: 40px; }

    /* Interface form: stack rows */
    .iface-form-row1 { flex-direction: column; }
    .iface-form-row1 input { width: 100%; flex: none; }
    .iface-form-row1 select { width: 100%; }
    .iface-form-row1 .btn { width: 100%; text-align: center; }

    /* Modals */
    .modal-body {
        width: 95%; max-width: none;
        max-height: 90vh; overflow-y: auto;
        padding: 1rem;
    }
    .modal-body textarea { height: 160px; font-size: 0.75rem; }
    .modal-body .btn-row { flex-wrap: wrap; justify-content: stretch; }
    .modal-body .btn-row .btn { flex: 1; text-align: center; }

    /* Status output */
    #status-text { max-height: 250px; font-size: 0.75rem; padding: 0.6rem; }

    /* Statusbar */
    .statusbar { padding: 0.3rem 0.75rem; font-size: 0.65rem; }

    /* Login page */
    .login-card { padding: 2rem 1.5rem; }
    .login-brand { font-size: 1.6rem; }
    .login-subtitle { font-size: 0.8rem; margin-bottom: 1.5rem; }
    .login-btn { font-size: 12px; padding: 10px 24px; }

    /* Restricted banner */
    .restricted-banner { font-size: 0.75rem; padding: 0.5rem 0.75rem; }
}
