/* ============================================================
   assets/css/style.css — Estilos globales de Muniportales
   Fuente: Inter (Google Fonts)
   Personalización: modificar variables en :root
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variables de tema (editables desde admin) ─────────────── */
:root {
    /* Navbar */
    --navbar-bg:          #0345bf;
    --navbar-text:        #ffffff;
    --navbar-hover-bg:    rgba(255,255,255,0.15);

    /* Sidebar */
    --sidebar-bg:         #f0f4ff;
    --sidebar-text:       #1a1a2e;
    --sidebar-active-bg:  #0345bf;
    --sidebar-active-text:#ffffff;
    --sidebar-hover-bg:   #d9e4ff;

    /* Contenido */
    --content-bg:         #f8f9fc;
    --content-text:       #333333;
    --card-bg:            #ffffff;
    --card-border:        #e2e8f0;
    --card-shadow:        0 2px 8px rgba(0,0,0,0.06);

    /* Footer */
    --footer-bg:          #0345bf;
    --footer-text:        #ffffff;

    /* Botones primarios */
    --btn-primary-bg:     #0345bf;
    --btn-primary-text:   #ffffff;
    --btn-primary-hover:  #0236a0;

    /* Botones secundarios */
    --btn-secondary-bg:   #6c757d;
    --btn-secondary-text: #ffffff;

    /* Botón peligro */
    --btn-danger-bg:      #dc3545;
    --btn-danger-text:    #ffffff;

    /* Botón éxito */
    --btn-success-bg:     #28a745;
    --btn-success-text:   #ffffff;

    /* Estados de tickets */
    --estado-pendiente:   #ffc107;
    --estado-en-proceso:  #17a2b8;
    --estado-resuelto:    #28a745;
    --estado-cerrado:     #6c757d;
    --estado-redirigido:  #fd7e14;

    /* Prioridades */
    --prior-baja:         #6c757d;
    --prior-media:        #17a2b8;
    --prior-alta:         #fd7e14;
    --prior-urgente:      #dc3545;

    /* Tipografía */
    --font-family:        'Inter', sans-serif;
    --font-size-base:     15px;
    --font-size-sm:       13px;
    --font-size-nav:      14px;
    --font-size-h1:       1.6rem;
    --font-size-h2:       1.3rem;

    /* Espaciado */
    --navbar-height:      60px;
    --sidebar-width:      240px;
    --border-radius:      8px;
    --border-radius-sm:   4px;
}

/* ── Reset y base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family:    var(--font-family);
    font-size:      var(--font-size-base);
    color:          var(--content-text);
    background:     var(--content-bg);
    min-height:     100vh;
    display:        flex;
    flex-direction: column;
}

a { color: var(--btn-primary-bg); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
    position:       fixed;
    top:            0; left: 0; right: 0;
    height:         var(--navbar-height);
    background:     var(--navbar-bg);
    color:          var(--navbar-text);
    display:        flex;
    align-items:    center;
    padding:        0 1.5rem;
    z-index:        1000;
    box-shadow:     0 2px 8px rgba(0,0,0,0.2);
    gap:            1rem;
}

.navbar-brand {
    font-size:   1.25rem;
    font-weight: 700;
    color:       var(--navbar-text);
    letter-spacing: 0.5px;
    text-decoration: none;
    white-space: nowrap;
}

.navbar-menu {
    display:     flex;
    align-items: center;
    gap:         0.25rem;
    list-style:  none;
    margin-left: 1.5rem;
    flex:        1;
}

.navbar-menu a {
    display:       block;
    color:         var(--navbar-text);
    font-size:     var(--font-size-nav);
    font-weight:   500;
    padding:       0.4rem 0.85rem;
    border-radius: var(--border-radius-sm);
    text-decoration: none;
    transition:    background 0.15s;
}

.navbar-menu a:hover,
.navbar-menu a.active {
    background: var(--navbar-hover-bg);
}

.navbar-right {
    display:     flex;
    align-items: center;
    gap:         1rem;
    margin-left: auto;
}

.navbar-user {
    font-size:   var(--font-size-sm);
    color:       var(--navbar-text);
    opacity:     0.9;
}

.navbar-notif {
    position:   relative;
    color:      var(--navbar-text);
    font-size:  1.15rem;
    cursor:     pointer;
}

.notif-badge {
    position:    absolute;
    top:         -6px; right: -7px;
    background:  #ff4444;
    color:       #fff;
    font-size:   10px;
    font-weight: 700;
    width:       17px; height: 17px;
    border-radius: 50%;
    display:     flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.btn-logout {
    background:    rgba(255,255,255,0.15);
    color:         var(--navbar-text);
    border:        1px solid rgba(255,255,255,0.3);
    padding:       0.35rem 0.85rem;
    border-radius: var(--border-radius-sm);
    font-size:     var(--font-size-sm);
    font-family:   var(--font-family);
    cursor:        pointer;
    transition:    background 0.15s;
    text-decoration: none;
}
.btn-logout:hover {
    background: rgba(255,255,255,0.28);
    text-decoration: none;
}

/* ── Layout principal ───────────────────────────────────────── */
.wrapper {
    display:    flex;
    flex:       1;
    margin-top: var(--navbar-height);
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    width:          var(--sidebar-width);
    min-height:     calc(100vh - var(--navbar-height));
    background:     var(--sidebar-bg);
    border-right:   1px solid var(--card-border);
    padding:        1.25rem 0;
    position:       fixed;
    top:            var(--navbar-height);
    left:           0;
    bottom:         0;
    overflow-y:     auto;
    z-index:        900;
}

.sidebar-section {
    padding:       0.5rem 1rem 0.25rem;
    font-size:     11px;
    font-weight:   600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color:         #888;
}

.sidebar-nav {
    list-style: none;
    padding:    0;
}

.sidebar-nav a {
    display:        flex;
    align-items:    center;
    gap:            0.6rem;
    padding:        0.55rem 1.25rem;
    color:          var(--sidebar-text);
    font-size:      var(--font-size-sm);
    font-weight:    500;
    text-decoration: none;
    transition:     background 0.12s, color 0.12s;
    border-left:    3px solid transparent;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover-bg);
}

.sidebar-nav a.active {
    background:  var(--sidebar-active-bg);
    color:       var(--sidebar-active-text);
    border-left: 3px solid rgba(255,255,255,0.5);
}

.sidebar-nav a i { width: 18px; text-align: center; font-size: 0.95rem; }

/* ── Área de contenido ──────────────────────────────────────── */
.main-content {
    margin-left:  var(--sidebar-width);
    flex:         1;
    padding:      1.75rem;
    min-height:   calc(100vh - var(--navbar-height) - 50px);
}

.page-title {
    font-size:   var(--font-size-h1);
    font-weight: 700;
    color:       var(--content-text);
    margin-bottom: 1.25rem;
    display:     flex;
    align-items: center;
    gap:         0.6rem;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background:    var(--card-bg);
    border:        1px solid var(--card-border);
    border-radius: var(--border-radius);
    box-shadow:    var(--card-shadow);
    padding:       1.5rem;
    margin-bottom: 1.25rem;
}

.card-title {
    font-size:   var(--font-size-h2);
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--card-border);
}

/* ── Botones ────────────────────────────────────────────────── */
.btn {
    display:       inline-flex;
    align-items:   center;
    gap:           0.4rem;
    padding:       0.5rem 1.1rem;
    border-radius: var(--border-radius-sm);
    font-family:   var(--font-family);
    font-size:     var(--font-size-sm);
    font-weight:   500;
    cursor:        pointer;
    border:        none;
    transition:    background 0.15s, opacity 0.15s;
    text-decoration: none;
    line-height:   1.4;
}

.btn-primary   { background: var(--btn-primary-bg);   color: var(--btn-primary-text); }
.btn-primary:hover { background: var(--btn-primary-hover); text-decoration: none; color: var(--btn-primary-text); }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); }
.btn-danger    { background: var(--btn-danger-bg);    color: var(--btn-danger-text); }
.btn-success   { background: var(--btn-success-bg);   color: var(--btn-success-text); }
.btn-sm        { padding: 0.3rem 0.75rem; font-size: 12px; }
.btn-lg        { padding: 0.65rem 1.4rem; font-size: var(--font-size-base); }
.btn:disabled  { opacity: 0.55; cursor: not-allowed; }

/* ── Formularios ────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

.form-label {
    display:       block;
    font-size:     var(--font-size-sm);
    font-weight:   500;
    margin-bottom: 0.35rem;
    color:         #444;
}

.form-control {
    width:         100%;
    padding:       0.5rem 0.75rem;
    border:        1px solid #ced4da;
    border-radius: var(--border-radius-sm);
    font-family:   var(--font-family);
    font-size:     var(--font-size-base);
    color:         var(--content-text);
    background:    #fff;
    transition:    border-color 0.15s, box-shadow 0.15s;
    outline:       none;
}

.form-control:focus {
    border-color: var(--btn-primary-bg);
    box-shadow:   0 0 0 3px rgba(3,69,191,0.12);
}

select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-text {
    font-size:  var(--font-size-sm);
    color:      #888;
    margin-top: 0.25rem;
}

.form-row {
    display: grid;
    gap:     1rem;
}
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── Tablas ─────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

.table {
    width:           100%;
    border-collapse: collapse;
    font-size:       var(--font-size-sm);
}

.table th {
    background:     var(--sidebar-bg);
    font-weight:    600;
    padding:        0.65rem 1rem;
    text-align:     left;
    border-bottom:  2px solid var(--card-border);
    white-space:    nowrap;
}

.table td {
    padding:        0.6rem 1rem;
    border-bottom:  1px solid var(--card-border);
    vertical-align: middle;
}

.table tr:hover td { background: #f8f9ff; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display:       inline-block;
    padding:       0.2rem 0.55rem;
    border-radius: 20px;
    font-size:     11px;
    font-weight:   600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.badge-pendiente  { background: #fff3cd; color: #856404; }
.badge-en-proceso { background: #d1ecf1; color: #0c5460; }
.badge-resuelto   { background: #d4edda; color: #155724; }
.badge-cerrado    { background: #e2e3e5; color: #383d41; }
.badge-redirigido { background: #fde8d8; color: #7a3200; }

.badge-baja     { background: #e2e3e5; color: #383d41; }
.badge-media    { background: #d1ecf1; color: #0c5460; }
.badge-alta     { background: #fde8d8; color: #7a3200; }
.badge-urgente  { background: #f8d7da; color: #721c24; }

/* ── Alertas ────────────────────────────────────────────────── */
.alert {
    padding:       0.85rem 1rem;
    border-radius: var(--border-radius-sm);
    font-size:     var(--font-size-sm);
    margin-bottom: 1rem;
    display:       flex;
    align-items:   flex-start;
    gap:           0.5rem;
}
.alert-success { background: #d4edda; color: #155724; border-left: 4px solid #28a745; }
.alert-danger  { background: #f8d7da; color: #721c24; border-left: 4px solid #dc3545; }
.alert-warning { background: #fff3cd; color: #856404; border-left: 4px solid #ffc107; }
.alert-info    { background: #d1ecf1; color: #0c5460; border-left: 4px solid #17a2b8; }

/* ── Chat / Historial de ticket ─────────────────────────────── */
.chat-container {
    display:        flex;
    flex-direction: column;
    gap:            1rem;
    padding:        1rem 0;
    max-height:     550px;
    overflow-y:     auto;
}

.chat-message {
    display:        flex;
    flex-direction: column;
    max-width:      70%;
}

/* Mensajes del usuario UIP — lado izquierdo */
.chat-message.from-user {
    align-self:  flex-start;
    align-items: flex-start;
}

/* Mensajes del técnico — lado derecho */
.chat-message.from-tecnico {
    align-self:  flex-end;
    align-items: flex-end;
}

.chat-bubble {
    padding:       0.7rem 1rem;
    border-radius: 16px;
    font-size:     var(--font-size-sm);
    line-height:   1.5;
    position:      relative;
    word-break:    break-word;
}

.from-user .chat-bubble {
    background:         #f0f4ff;
    border:             1px solid #c7d7ff;
    border-bottom-left-radius: 4px;
}

.from-tecnico .chat-bubble {
    background:          #0345bf;
    color:               #fff;
    border-bottom-right-radius: 4px;
}

.chat-meta {
    font-size:   11px;
    color:       #999;
    margin-top:  0.25rem;
    padding:     0 0.25rem;
}

.from-tecnico .chat-meta { color: #aaa; }

.chat-attachment {
    display:       inline-flex;
    align-items:   center;
    gap:           0.35rem;
    margin-top:    0.4rem;
    font-size:     12px;
    padding:       0.25rem 0.6rem;
    border-radius: 4px;
    background:    rgba(0,0,0,0.07);
    text-decoration: none;
}

.from-tecnico .chat-attachment { background: rgba(255,255,255,0.2); color: #fff; }

/* Área de respuesta */
.reply-area {
    border-top:  2px solid var(--card-border);
    padding-top: 1.25rem;
    margin-top:  0.5rem;
}

/* ── Dashboard stats ────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background:    var(--card-bg);
    border:        1px solid var(--card-border);
    border-radius: var(--border-radius);
    padding:       1.25rem;
    text-align:    center;
    box-shadow:    var(--card-shadow);
    border-top:    4px solid var(--btn-primary-bg);
}

.stat-card .stat-number {
    font-size:   2rem;
    font-weight: 700;
    color:       var(--btn-primary-bg);
    line-height: 1;
}

.stat-card .stat-label {
    font-size:  var(--font-size-sm);
    color:      #777;
    margin-top: 0.4rem;
}

/* ── Paginación ─────────────────────────────────────────────── */
.pagination {
    display:     flex;
    gap:         0.3rem;
    margin-top:  1rem;
    flex-wrap:   wrap;
}

.pagination a,
.pagination span {
    display:       inline-block;
    padding:       0.35rem 0.75rem;
    border:        1px solid var(--card-border);
    border-radius: var(--border-radius-sm);
    font-size:     var(--font-size-sm);
    text-decoration: none;
    color:         var(--content-text);
    background:    var(--card-bg);
    transition:    background 0.12s;
}

.pagination a:hover { background: var(--sidebar-hover-bg); }
.pagination .active { background: var(--btn-primary-bg); color: #fff; border-color: var(--btn-primary-bg); }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
    display:         none;
    position:        fixed;
    inset:           0;
    background:      rgba(0,0,0,0.45);
    z-index:         2000;
    align-items:     center;
    justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
    background:    var(--card-bg);
    border-radius: var(--border-radius);
    padding:       2rem;
    width:         90%;
    max-width:     560px;
    max-height:    90vh;
    overflow-y:    auto;
    box-shadow:    0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
    display:       flex;
    align-items:   center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.modal-close {
    background: none;
    border:     none;
    font-size:  1.4rem;
    cursor:     pointer;
    color:      #888;
    line-height:1;
}

/* ── Footer ─────────────────────────────────────────────────── */
footer {
    background:   var(--footer-bg);
    color:        var(--footer-text);
    text-align:   center;
    padding:      0.85rem 1.5rem;
    font-size:    var(--font-size-sm);
    margin-left:  var(--sidebar-width);
}

/* ── Login page (sin sidebar) ───────────────────────────────── */
.login-page {
    min-height:      100vh;
    display:         flex;
    align-items:     center;
    justify-content: center;
    background:      linear-gradient(135deg, #0345bf 0%, #0255e5 50%, #1a6aff 100%);
}

.login-card {
    background:    #fff;
    border-radius: 12px;
    padding:       2.5rem 2rem;
    width:         100%;
    max-width:     420px;
    box-shadow:    0 12px 40px rgba(0,0,0,0.2);
}

.login-logo {
    text-align:    center;
    margin-bottom: 1.75rem;
}

.login-logo h1 {
    color:       var(--btn-primary-bg);
    font-size:   1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.login-logo p {
    color:     #888;
    font-size: var(--font-size-sm);
}

/* ── Reportes ───────────────────────────────────────────────── */
@media print {
    .navbar, .sidebar, footer, .btn, .no-print { display: none !important; }
    .main-content { margin: 0; padding: 0; }
    body { background: #fff; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}

.report-header {
    text-align:    center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--btn-primary-bg);
}

.report-header h2 { color: var(--btn-primary-bg); font-size: 1.4rem; }
.report-header p  { color: #666; font-size: var(--font-size-sm); margin-top: 0.25rem; }

/* ── Utilidades ─────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: #888; font-size: var(--font-size-sm); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex-1 { flex: 1; }
.w-100 { width: 100%; }
.fw-600 { font-weight: 600; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    :root { --sidebar-width: 0px; }
    .sidebar  { transform: translateX(-240px); width: 240px; transition: transform 0.25s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 1rem; }
    footer { margin-left: 0; }
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .chat-message { max-width: 90%; }
}
