/**
 * CSS del Panel de Agencia Frontend
 *
 * Estilos completos para el dashboard multi-agencia accesible desde el frontend.
 * Diseño moderno, responsive, alineado con la identidad 360group.ai.
 */

/* ==========================================================================
   Reset & Variables
   ========================================================================== */
.ai360r-frontend-wrapper {
    --r-bg: #f8fafc;
    --r-surface: #ffffff;
    --r-border: #e2e8f0;
    --r-text: #1e293b;
    --r-text-muted: #64748b;
    --r-primary: #2563eb;
    --r-primary-hover: #1d4ed8;
    --r-success: #16a34a;
    --r-success-hover: #15803d;
    --r-danger: #dc2626;
    --r-danger-hover: #b91c1c;
    --r-radius: 8px;
    --r-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --r-shadow-lg: 0 10px 40px rgba(0,0,0,0.12);

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    color: var(--r-text);
    background: var(--r-bg);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.ai360r-frontend-wrapper *,
.ai360r-frontend-wrapper *::before,
.ai360r-frontend-wrapper *::after {
    box-sizing: border-box;
}

/* ==========================================================================
   Login Card
   ========================================================================== */
.ai360r-login-card {
    max-width: 420px;
    margin: 80px auto;
    background: var(--r-surface);
    border-radius: var(--r-radius);
    box-shadow: var(--r-shadow-lg);
    overflow: hidden;
}

.ai360r-login-header {
    text-align: center;
    padding: 40px 30px 20px;
    background: linear-gradient(135deg, #1e3a5f, #2563eb);
    color: #fff;
}

.ai360r-login-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.ai360r-login-header h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}

.ai360r-login-header p {
    margin: 8px 0 0;
    font-size: 14px;
    opacity: 0.85;
}

.ai360r-login-form {
    padding: 30px;
}

.ai360r-login-footer {
    text-align: center;
    padding: 0 30px 30px;
    font-size: 13px;
    color: var(--r-text-muted);
}

/* ==========================================================================
   Header
   ========================================================================== */
.ai360r-fd-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #1e3a5f, #2563eb);
    color: #fff;
    padding: 0 24px;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.ai360r-fd-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai360r-fd-logo {
    font-weight: 700;
    font-size: 16px;
}

.ai360r-fd-badge {
    background: rgba(255,255,255,0.2);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai360r-fd-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.ai360r-fd-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.ai360r-fd-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.ai360r-fd-logout {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 4px;
    transition: all 0.2s;
}

.ai360r-fd-logout:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* ==========================================================================
   Layout
   ========================================================================== */
.ai360r-fd-container {
    display: flex;
    min-height: calc(100vh - 56px);
    max-width: 1400px;
    margin: 0 auto;
}

/* Sidebar */
.ai360r-fd-sidebar {
    width: 220px;
    background: var(--r-surface);
    border-right: 1px solid var(--r-border);
    padding: 20px 0;
    flex-shrink: 0;
}

.ai360r-fd-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ai360r-fd-sidebar li {
    margin: 0;
}

.ai360r-fd-sidebar li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    color: var(--r-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.ai360r-fd-sidebar li a:hover {
    background: #f1f5f9;
    color: var(--r-primary);
}

.ai360r-fd-sidebar li.active a {
    background: #eff6ff;
    color: var(--r-primary);
    border-left-color: var(--r-primary);
}

/* Main */
.ai360r-fd-main {
    flex: 1;
    padding: 24px 32px;
    min-width: 0;
}

/* ==========================================================================
   Status Bar
   ========================================================================== */
.ai360r-fd-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--r-surface);
    border: 1px solid var(--r-border);
    border-radius: var(--r-radius);
    margin-bottom: 24px;
    font-size: 13px;
    color: var(--r-text-muted);
}

.ai360r-fd-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.ai360r-fd-status-dot.online {
    background: var(--r-success);
    box-shadow: 0 0 0 3px rgba(22,163,74,0.2);
}

.ai360r-fd-status-dot.offline {
    background: var(--r-danger);
    box-shadow: 0 0 0 3px rgba(220,38,38,0.2);
}

.ai360r-fd-latency {
    margin-left: auto;
    font-weight: 600;
    color: var(--r-text);
}

/* ==========================================================================
   Messages
   ========================================================================== */
.ai360r-message {
    padding: 12px 16px;
    border-radius: var(--r-radius);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

.ai360r-message--success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.ai360r-message--error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ==========================================================================
   Connections Section
   ========================================================================== */
.ai360r-fd-section {
    margin-bottom: 40px;
}

.ai360r-fd-section-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.ai360r-fd-section-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.ai360r-fd-section-desc {
    font-size: 13px;
    color: var(--r-text-muted);
    margin-bottom: 20px;
    line-height: 1.5;
}

.ai360r-fd-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    margin-left: 8px;
    background: var(--r-border);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--r-text-muted);
}

/* Connection Cards */
.ai360r-fd-connections {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai360r-fd-conn-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--r-surface);
    border: 1px solid var(--r-border);
    border-radius: var(--r-radius);
    padding: 16px 20px;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.ai360r-fd-conn-card:hover {
    box-shadow: var(--r-shadow);
    border-color: #cbd5e1;
}

.ai360r-fd-conn-icon {
    font-size: 28px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border-radius: 10px;
    flex-shrink: 0;
}

.ai360r-fd-conn-info {
    flex: 1;
    min-width: 0;
}

.ai360r-fd-conn-info h3 {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
}

.ai360r-fd-conn-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.ai360r-fd-protocol-tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
}

.ai360r-fd-protocol-tag.rdp { background: #2563eb; }
.ai360r-fd-protocol-tag.vnc { background: #dc2626; }
.ai360r-fd-protocol-tag.ssh { background: #1e293b; }

.ai360r-fd-conn-host {
    color: var(--r-text-muted);
    font-family: 'SF Mono', 'Consolas', monospace;
    font-size: 12px;
}

.ai360r-fd-conn-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ==========================================================================
   Empty State
   ========================================================================== */
.ai360r-fd-empty {
    text-align: center;
    padding: 60px 20px;
    background: var(--r-surface);
    border: 2px dashed var(--r-border);
    border-radius: var(--r-radius);
}

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

.ai360r-fd-empty h3 {
    margin: 0 0 8px;
    font-size: 16px;
    color: var(--r-text);
}

.ai360r-fd-empty p {
    margin: 0;
    font-size: 14px;
    color: var(--r-text-muted);
}

/* ==========================================================================
   Add Connection Form
   ========================================================================== */
.ai360r-fd-form {
    background: var(--r-surface);
    border: 1px solid var(--r-border);
    border-radius: var(--r-radius);
    padding: 24px;
}

.ai360r-fd-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

/* ==========================================================================
   Fields & Buttons
   ========================================================================== */
.ai360r-field {
    margin-bottom: 16px;
}

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

.ai360r-field input[type="text"],
.ai360r-field input[type="email"],
.ai360r-field input[type="password"],
.ai360r-field input[type="number"],
.ai360r-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--r-border);
    border-radius: 6px;
    font-size: 14px;
    color: var(--r-text);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.ai360r-field input:focus,
.ai360r-field select:focus {
    border-color: var(--r-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.ai360r-checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    font-weight: 400 !important;
    cursor: pointer;
    color: var(--r-text-muted);
    font-size: 13px;
}

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

/* Buttons */
.ai360r-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    line-height: 1;
}

.ai360r-btn--primary {
    background: var(--r-primary);
    color: #fff;
}

.ai360r-btn--primary:hover {
    background: var(--r-primary-hover);
    color: #fff;
}

.ai360r-btn--success {
    background: var(--r-success);
    color: #fff;
}

.ai360r-btn--success:hover {
    background: var(--r-success-hover);
    color: #fff;
}

.ai360r-btn--danger {
    background: transparent;
    color: var(--r-danger);
    border: 1px solid #fecaca;
}

.ai360r-btn--danger:hover {
    background: #fef2f2;
}

.ai360r-btn--full {
    width: 100%;
    justify-content: center;
    padding: 12px;
}

.ai360r-btn--sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
    .ai360r-fd-sidebar {
        display: none;
    }

    .ai360r-fd-main {
        padding: 16px;
    }

    .ai360r-fd-form-grid {
        grid-template-columns: 1fr;
    }

    .ai360r-fd-conn-card {
        flex-wrap: wrap;
    }

    .ai360r-fd-conn-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 8px;
    }

    .ai360r-login-card {
        margin: 20px;
    }

    .ai360r-fd-header {
        padding: 0 16px;
    }
}

@media (max-width: 480px) {
    .ai360r-fd-header-right .ai360r-fd-user {
        display: none;
    }
}

/* ==========================================================================
   Support Session Cards
   ========================================================================== */
.ai360r-support-section {
    margin-top: 0;
}

.ai360r-fd-card-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 16px;
}

.ai360r-fd-card {
    background: var(--r-surface);
    border: 1px solid var(--r-border);
    border-radius: var(--r-radius);
    padding: 24px;
    box-shadow: var(--r-shadow);
}

.ai360r-fd-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--r-text);
}

.ai360r-fd-card .ai360r-field {
    margin-bottom: 14px;
}

.ai360r-fd-card .ai360r-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--r-text-muted);
    margin-bottom: 4px;
}

.ai360r-fd-card .ai360r-field input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--r-border);
    border-radius: 6px;
    font-size: 14px;
    color: var(--r-text);
    background: #fff;
    transition: border-color 0.2s;
}

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

.ai360r-fd-card .ai360r-btn--primary {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    justify-content: center;
}

.ai360r-message--success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
    padding: 12px 16px;
    border-radius: var(--r-radius);
    margin-bottom: 16px;
    font-size: 14px;
}

@media (max-width: 768px) {
    .ai360r-fd-card-row {
        grid-template-columns: 1fr;
    }
}
