/* =========================================
   VARIABLES & DESIGN TOKENS (Smart City)
   ========================================= */
:root {
    --primary-color: #0d6efd; /* Azul Institucional */
    --primary-hover: #0b5ed7;
    --secondary-color: #f8f9fa;
    --accent-color: #20c997; /* Verde Salud */
    --danger-color: #dc3545; /* Alertas / Riesgo */
    --warning-color: #ffc107;
    
    --bg-gradient: linear-gradient(135deg, #f0f4f8 0%, #d9e2ec 100%);
    --card-bg: rgba(255, 255, 255, 0.85);
    --text-main: #2d3748;
    --text-muted: #718096;
    
    --border-radius: 16px;
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --glass-border: 1px solid rgba(255, 255, 255, 0.4);
    
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* =========================================
   BASE & RESET
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

/* =========================================
   TYPOGRAPHY
   ========================================= */
h1, h2, h3 {
    color: #1a202c;
    font-weight: 700;
}

/* =========================================
   HEADER
   ========================================= */
.main-header {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: var(--glass-border);
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
}

.brand-text h1 {
    font-size: 1.4rem;
    margin-bottom: 0.2rem;
}

.brand-text span {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* =========================================
   BUTTONS & INPUTS
   ========================================= */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 10px rgba(13, 110, 253, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(13, 110, 253, 0.4);
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

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

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

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

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.btn-icon {
    padding: 0.4rem;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* =========================================
   MAIN LAYOUT & CARDS
   ========================================= */
.main-content {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    flex-grow: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--border-radius);
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    padding: 2rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.card-header h2 {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
}

/* =========================================
   SEARCH & TABLE
   ========================================= */
.search-box {
    position: relative;
    width: 100%;
    max-width: 300px;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.5rem;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    outline: none;
    font-size: 0.95rem;
    transition: var(--transition);
    background: #f8fafc;
}

.search-box input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.data-table th, .data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #edf2f7;
}

.data-table th {
    background: rgba(247, 250, 252, 0.8);
    font-weight: 600;
    color: #4a5568;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.data-table tr:hover td {
    background: rgba(247, 250, 252, 0.5);
}

.status-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-ok {
    background: #def7ec;
    color: #03543f;
}

.status-warning {
    background: #fefcbf;
    color: #744210;
}

.status-danger {
    background: #fed7d7;
    color: #822727;
}

/* =========================================
   MODALS
   ========================================= */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal:not(.hidden) {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    width: 100%;
    max-width: 450px;
    position: relative;
    transform: translateY(-20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal:not(.hidden) .modal-content {
    transform: translateY(0);
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}

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

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
}

.form-group input {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    outline: none;
    transition: var(--transition);
}

.form-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.form-help {
    display: block;
    margin-top: 0.3rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 0.8rem;
    font-size: 1rem;
    margin-top: 1rem;
}

.error-message {
    background: #fed7d7;
    color: #822727;
    padding: 0.8rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border-left: 4px solid var(--danger-color);
}

/* =========================================
   VIRTUAL ASSISTANT
   ========================================= */
.virtual-assistant {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    z-index: 999;
}

.chat-bubble {
    background: white;
    padding: 1rem;
    border-radius: 16px 16px 0 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
    position: relative;
    max-width: 250px;
    font-size: 0.9rem;
    line-height: 1.4;
    border: 1px solid #e2e8f0;
    animation: floatBubble 3s ease-in-out infinite;
}

.chat-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    right: 20px;
    border-width: 10px 10px 0 0;
    border-style: solid;
    border-color: white transparent transparent transparent;
}

.btn-close-chat {
    position: absolute;
    top: 5px;
    right: 5px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
}

.avatar-container {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    overflow: hidden;
    border: 3px solid white;
    cursor: pointer;
    transition: var(--transition);
}

.avatar-container:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 30px rgba(0,0,0,0.2);
}

.avatar-3d {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@keyframes floatBubble {
    0% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0); }
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(13, 110, 253, 0.2);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .brand {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .search-box {
        max-width: 100%;
    }
    
    .virtual-assistant {
        bottom: 1rem;
        right: 1rem;
    }
    
    .avatar-container {
        width: 80px;
        height: 80px;
    }
}
