/**
 * Estilos do Painel N-GATEWAY
 * NTECH NETWORK E COMUNICAÇÃO LTDA
 */

/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 260px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-800);
    background-color: var(--gray-100);
}

a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ==================== LOGIN PAGE ==================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-box {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

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

.company-logo {
    margin-bottom: 20px;
}

.company-logo img {
    max-width: 180px;
    max-height: 80px;
    object-fit: contain;
}

.logo-fallback {
    width: 80px;
    height: 80px;
    margin: 0 auto;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: 16px;
    display: none;
    align-items: center;
    justify-content: center;
}

.logo-icon {
    font-size: 40px;
}

.logo-text {
    font-size: 24px;
    font-weight: 800;
    color: white;
    letter-spacing: 2px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.login-header p {
    color: var(--gray-500);
    font-size: 14px;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-weight: 500;
    color: var(--gray-700);
    font-size: 14px;
}

.form-group input {
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.login-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--gray-500);
}

.copyright {
    text-align: center;
    margin-top: 24px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.copyright p {
    margin: 4px 0;
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

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

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

.btn-danger {
    background: var(--danger-color);
    color: white;
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}

.btn-outline:hover {
    background: var(--gray-100);
}

.btn-block {
    width: 100%;
}

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

/* ==================== ALERTS ==================== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert a {
    color: inherit;
    text-decoration: underline;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
}

/* ==================== DASHBOARD LAYOUT ==================== */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-700);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo img {
    max-width: 40px;
    max-height: 40px;
    border-radius: 8px;
}

.logo-fallback-small {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
}

.sidebar-title h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 2px;
}

.router-name {
    font-size: 11px;
    color: var(--gray-400);
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--gray-300);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--gray-800);
    color: white;
    text-decoration: none;
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-text {
    font-size: 14px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-700);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-icon {
    font-size: 16px;
}

.user-name {
    font-size: 13px;
    color: var(--gray-300);
}

.sidebar-footer .btn-outline {
    border-color: var(--gray-600);
    color: var(--gray-300);
}

.sidebar-footer .btn-outline:hover {
    background: var(--gray-800);
    border-color: var(--gray-500);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px 32px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

.content-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

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

.last-update {
    font-size: 12px;
    color: var(--gray-500);
}

.connection-count {
    font-size: 12px;
    color: var(--gray-600);
    background: var(--gray-200);
    padding: 4px 10px;
    border-radius: 12px;
}

/* ==================== STATS GRID ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.stat-card-link {
    text-decoration: none;
    color: inherit;
}

.stat-card-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.connected { background: #dbeafe; }
.stat-icon.users { background: #fef3c7; }
.stat-icon.uptime { background: #d1fae5; }
.stat-icon.cpu { background: #fce7f3; }

.stat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-value-small {
    font-size: 16px;
}

.stat-label {
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==================== CONTENT SECTION ==================== */
.content-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.content-section h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.section-description {
    color: var(--gray-600);
    margin-bottom: 24px;
    margin-top: -12px;
}

/* ==================== VPN SERVERS GRID ==================== */
.vpn-servers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.server-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
    transition: all 0.2s;
}

.server-card.active {
    border-color: var(--success-color);
    background: #f0fdf4;
}

.server-card.inactive {
    border-color: var(--gray-300);
    background: var(--gray-50);
}

.server-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-bottom: 12px;
}

.server-status.online {
    background: var(--success-color);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.server-status.offline {
    background: var(--gray-400);
}

.server-name {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.server-state {
    font-size: 12px;
    color: var(--gray-500);
}

/* ==================== TABLES ==================== */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    font-weight: 600;
    color: var(--gray-600);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--gray-50);
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.data-table tbody tr.row-online {
    background: #f0fdf4;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.status-dot.online {
    background: var(--success-color);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.status-dot.offline {
    background: var(--gray-400);
}

code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 12px;
}

.uptime-badge {
    font-size: 13px;
    color: var(--gray-700);
}

.text-muted {
    color: var(--gray-400);
}

/* ==================== BADGES ==================== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-secondary {
    background: var(--gray-200);
    color: var(--gray-600);
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}

/* ==================== SEARCH / TOOLBAR ==================== */
.section-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.search-box input::placeholder {
    color: var(--gray-400);
}

.search-filters select {
    padding: 10px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    min-width: 150px;
}

.search-filters select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-info {
    font-size: 13px;
    color: var(--gray-500);
    white-space: nowrap;
}

.search-info span {
    font-weight: 600;
    color: var(--gray-700);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--gray-700);
    margin-bottom: 8px;
}

/* ==================== SYSTEM INFO GRID ==================== */
.system-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 8px;
}

.info-label {
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-weight: 600;
    color: var(--gray-900);
}

/* ==================== CONFIG FORM ==================== */
.config-form {
    max-width: 700px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group .required {
    color: var(--danger-color);
}

.form-help {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

/* ==================== INSTRUCTIONS ==================== */
.instructions {
    color: var(--gray-700);
}

.instructions h3 {
    font-size: 14px;
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 8px;
}

.instructions h3:first-child {
    margin-top: 0;
}

.instructions p {
    margin-bottom: 8px;
}

.code-block {
    background: var(--gray-900);
    color: #e5e7eb;
    padding: 12px 16px;
    border-radius: 8px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.config-info {
    background: var(--gray-50);
    padding: 16px;
    border-radius: 8px;
}

.config-info p {
    margin: 4px 0;
}

/* ==================== FOOTER ==================== */
.main-footer {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
    text-align: center;
}

/* ==================== MODAL ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    margin: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--gray-700);
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    margin-bottom: 16px;
    color: var(--gray-600);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: 0 0 12px 12px;
}

/* ==================== INPUT WITH UNIT ==================== */
.input-with-unit {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-with-unit input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
}

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

.input-unit {
    color: var(--gray-500);
    font-size: 14px;
    white-space: nowrap;
}

.info-display {
    padding: 12px 16px;
    background: var(--gray-100);
    border-radius: 8px;
    color: var(--gray-700);
    font-weight: 500;
}

/* ==================== ADD USER SECTION ==================== */
.add-user-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

.add-user-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--gray-800);
}

/* ==================== ACTION BUTTONS ==================== */
.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ==================== USER DETAILS IN SIDEBAR ==================== */
.user-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-role {
    font-size: 11px;
    color: var(--gray-500);
}

/* ==================== SIDEBAR CLIENT INFO ==================== */
.sidebar-client-info {
    padding: 12px 20px;
    background: var(--gray-800);
    border-bottom: 1px solid var(--gray-700);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.client-label {
    font-size: 11px;
    color: var(--gray-400);
}

.client-name {
    font-size: 13px;
    color: white;
}

.change-client {
    font-size: 11px;
    color: var(--primary-light);
    text-decoration: none;
    margin-left: auto;
}

.change-client:hover {
    text-decoration: underline;
}

/* ==================== CURRENT CLIENT BADGE ==================== */
.current-client-badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

/* ==================== ACTIVE CLIENT SECTION ==================== */
.active-client-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 16px 24px !important;
}

.active-client-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.active-client-label {
    font-size: 12px;
    opacity: 0.8;
}

.active-client-name {
    font-size: 18px;
}

.active-client-host {
    font-size: 12px;
    opacity: 0.7;
}

/* ==================== CLIENTS GRID ==================== */
.clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.client-card {
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
}

.client-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.client-card.selected {
    border-color: var(--success-color);
    background: #f0fdf4;
}

.client-card.inactive {
    opacity: 0.6;
}

.client-card-header {
    padding: 16px 20px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 12px;
}

.client-card-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.client-card-body {
    padding: 16px 20px;
}

.client-card-body p {
    margin: 4px 0;
    font-size: 13px;
    color: var(--gray-600);
}

.client-card-actions {
    padding: 12px 20px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ==================== ALERT WARNING ==================== */
.alert-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

/* ==================== MODAL LARGE ==================== */
.modal-large {
    max-width: 600px;
}

/* ==================== CHECKBOX LABEL ==================== */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

/* ==================== EMPTY STATE SMALL ==================== */
.empty-state.small {
    padding: 30px 20px;
}

.empty-state.small p {
    margin: 0;
}

.footer-content {
    color: var(--gray-500);
    font-size: 12px;
}

.footer-content p {
    margin: 2px 0;
}

.footer-sub {
    color: var(--gray-400);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
    }
    
    .main-content {
        margin-left: 0;
        padding: 16px;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
}

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