/* ============================================
   Bastion — Stylesheet
   ============================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f1117;
    color: #e0e0e0;
    min-height: 100vh;
}

/* ============================================
   Login
   ============================================ */

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-box {
    background: #1a1d27;
    padding: 40px;
    border-radius: 12px;
    width: 360px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 4px;
    font-size: 28px;
    color: #fff;
}

.login-box .subtitle {
    text-align: center;
    color: #888;
    margin-bottom: 30px;
    font-size: 14px;
}

.login-box input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 14px;
    border: 1px solid #333;
    border-radius: 8px;
    background: #0f1117;
    color: #e0e0e0;
    font-size: 14px;
}

.login-box input:focus {
    outline: none;
    border-color: #4a9eff;
}

.login-box button {
    width: 100%;
    padding: 12px;
    background: #4a9eff;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.login-box button:hover {
    background: #3a8eef;
}

.error {
    color: #ff6b6b;
    text-align: center;
    margin-top: 12px;
    font-size: 14px;
}

/* ============================================
   Dashboard
   ============================================ */

.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #2a2d37;
}

.header-left h1 {
    font-size: 24px;
    color: #fff;
}

.user-info {
    font-size: 13px;
    color: #888;
}

.header-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.refresh-info {
    font-size: 12px;
    color: #555;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.btn-sm {
    padding: 6px 12px;
}

.btn {
    background: #2a2d37;
    color: #e0e0e0;
}

.btn:hover {
    background: #3a3d47;
}

.btn-primary {
    background: #4a9eff;
    color: #fff;
}

.btn-primary:hover {
    background: #3a8eef;
}

.btn-danger {
    background: #ff4757;
    color: #fff;
}

.btn-danger:hover {
    background: #e0414f;
}

.btn-warning {
    background: #f59e0b;
    color: #000;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-info {
    background: #3b82f6;
    color: #fff;
}

.btn-info:hover {
    background: #2563eb;
}

.btn-success {
    background: #22c55e;
    color: #fff;
}

.btn-success:hover {
    background: #16a34a;
}

/* Stats bar */
.stats-bar {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}

.stat {
    background: #1a1d27;
    padding: 16px 24px;
    border-radius: 8px;
    text-align: center;
    min-width: 100px;
}

.stat-value {
    font-size: 28px;
    font-weight: bold;
    display: block;
    color: #fff;
}

.stat-value.online {
    color: #2ed573;
}

.stat-value.offline {
    color: #ff4757;
}

.stat-label {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    background: #1a1d27;
    border-radius: 8px;
    overflow: hidden;
}

th {
    background: #22252f;
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    font-weight: 600;
}

td {
    padding: 12px 16px;
    border-top: 1px solid #2a2d37;
    font-size: 14px;
}

tr:hover {
    background: #22252f;
}

.loading {
    text-align: center;
    color: #888;
    padding: 40px !important;
}

/* Status badge */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-connected {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-online {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-offline {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-pending {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* OS badge */
.os-badge {
    font-size: 12px;
    color: #aaa;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-container {
        padding: 10px;
    }

    header {
        flex-direction: column;
        gap: 10px;
    }

    .stats-bar {
        flex-wrap: wrap;
    }

    table {
        font-size: 12px;
    }

    th, td {
        padding: 8px 10px;
    }
}

/* ============================================
   Forms & Sections
   ============================================ */

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

.section-header h2 {
    color: #fff;
}

.form-box {
    background: #1a1d27;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.form-box h3 {
    color: #fff;
    margin-bottom: 16px;
}

.form-box input,
.form-box select {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 12px;
    border: 1px solid #333;
    border-radius: 6px;
    background: #0f1117;
    color: #e0e0e0;
    font-size: 14px;
}

.form-box input:focus,
.form-box select:focus {
    outline: none;
    border-color: #4a9eff;
}

.form-actions {
    display: flex;
    gap: 10px;
}

/* Filters */
.filters-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.filters-bar select {
    padding: 8px 12px;
    border: 1px solid #333;
    border-radius: 6px;
    background: #1a1d27;
    color: #e0e0e0;
    font-size: 13px;
}

/* Protocol select (inline na tabela) */
.proto-select {
    padding: 4px 8px;
    border: 1px solid #333;
    border-radius: 4px;
    background: #0f1117;
    color: #e0e0e0;
    font-size: 12px;
    margin-right: 6px;
    vertical-align: middle;
}

/* Navigation links as buttons */
a.btn {
    text-decoration: none;
    display: inline-block;
}

/* Assigned devices tags */
.assigned-devices-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-bottom: 4px;
}

.assigned-device-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.85em;
}

.assigned-device-tag .remove-btn {
    cursor: pointer;
    color: #ff6b6b;
    font-weight: bold;
    margin-left: 4px;
}

.assigned-device-tag .remove-btn:hover {
    color: #ff4757;
}

/* Role buttons */
.btn-role-promote {
    background: #2a5a2a;
    color: #a0d0a0;
    border: 1px solid #3a7a3a;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.8em;
    cursor: pointer;
    margin-left: 6px;
}
.btn-role-promote:hover {
    background: #3a7a3a;
}

.btn-role-demote {
    background: #5a3a2a;
    color: #d0a0a0;
    border: 1px solid #7a4a3a;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.8em;
    cursor: pointer;
    margin-left: 6px;
}
.btn-role-demote:hover {
    background: #7a4a3a;
}

/* Download link */
.download-link {
    display: block;
    text-align: center;
    margin-top: 20px;
    color: #888;
    font-size: 0.85em;
    text-decoration: none;
}
.download-link:hover {
    color: #b0b0d0;
    text-decoration: underline;
}

/* Group select/badge */
.group-select {
    background: #2a2a3e;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.85em;
}

.group-badge {
    background: #3a3a5e;
    color: #b0b0d0;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8em;
    white-space: nowrap;
}

/* Assigned groups tags */
.assigned-groups-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-bottom: 4px;
}

.assigned-group-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(100, 100, 255, 0.1);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 0.85em;
}

.assigned-group-tag .remove-btn {
    cursor: pointer;
    color: #ff6b6b;
    font-weight: bold;
    margin-left: 4px;
}

.assigned-group-tag .remove-btn:hover {
    color: #ff4757;
}

/* Tunnel error */
.tunnel-error {
    display: inline-block;
    margin-left: 8px;
    color: #ff6b6b;
    font-size: 12px;
    cursor: help;
}

/* Code inline */
code {
    background: #22252f;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: #4a9eff;
}
