/* css/style.css */
:root {
    --sidebar-w: 260px;
    --sidebar-col-w: 70px;
    --primary: #0A2540;
    --primary-hover: #12385e;
    --accent: #0073e6;
    --bg-main: #f4f6f9;
    --card-bg: #ffffff;
    --border: #e0e6ed;
    --text-main: #202124;
    --text-muted: #5f6368;
    --success-bg: #d4edda;
    --success-text: #155724;
    --danger-bg: #f8d7da;
    --danger-text: #721c24;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    list-style: none;
    text-decoration: none;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.5;
}

/* Layout con Sidebar */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    background-color: var(--primary);
    color: #fff;
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
}

.sidebar.collapsed { width: var(--sidebar-col-w); }

.sidebar-header {
    padding: 1.2rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand { font-weight: bold; font-size: 1.1rem; white-space: nowrap; overflow: hidden; }
.sidebar.collapsed .sidebar-brand, .sidebar.collapsed .nav-text { display: none; }

.toggle-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px 8px;
}

.sidebar-nav { padding: 1rem 0; flex-grow: 1; }
.sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.2rem;
    color: rgba(255,255,255,0.8);
    transition: background 0.2s;
}
.sidebar-nav li a:hover, .sidebar-nav li a.active {
    background-color: rgba(255,255,255,0.15);
    color: #fff;
}
.sidebar-nav .icon { font-size: 1.2rem; min-width: 35px; }

.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255,255,255,0.1); }

.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-w);
    transition: margin-left 0.3s ease;
    padding: 2rem;
}
.sidebar.collapsed + .main-content { margin-left: var(--sidebar-col-w); }

/* Componentes UI */
.card-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
    margin-bottom: 1.5rem;
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.section-title {
    grid-column: 1 / -1;
    font-weight: bold;
    border-bottom: 2px solid var(--border);
    padding-bottom: 4px;
    margin-top: 10px;
    color: var(--primary);
}

.form-group { text-align: left; }
.form-group label { display: block; font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; }
.form-control {
    width: 100%;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
}

.btn {
    display: inline-block;
    padding: 0.65rem 1.2rem;
    border-radius: 6px;
    border: none;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; border-radius: 4px; }
.btn-success { background: #28a745; }
.btn-info { background: #17a2b8; }
.btn-secondary { background: #6c757d; }

.table-responsive { overflow-x: auto; margin-top: 1rem; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.9rem; }
th, td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
th { background: #f8f9fa; color: var(--text-muted); font-weight: 600; }

.alert { padding: 0.8rem 1rem; border-radius: 6px; margin-bottom: 1.2rem; font-weight: 500; }
.alert-exito { background-color: var(--success-bg); color: var(--success-text); }
.alert-error { background-color: var(--danger-bg); color: var(--danger-text); }

/* Ficha de Expediente (Bloques) */
.bloques-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.5rem; }
.bloque-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 1.2rem; }
.bloque-header { font-weight: bold; color: var(--primary); border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-bottom: 10px; }
.item-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed #f1f3f4; font-size: 0.85rem; }
.item-label { color: var(--text-muted); font-weight: 600; }

/* Credencial Oficial CR80 (85.6mm x 53.98mm) */
#modalImpresion {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.credencial-card {
    width: 85.6mm;
    height: 53.98mm;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 3mm;
    background: #fff;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-family: Arial, sans-serif;
    text-align: left;
}
.credencial-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--primary); padding-bottom: 2mm; }
.credencial-header img { height: 8mm; max-width: 40mm; object-fit: contain; }
.credencial-body { display: flex; gap: 3mm; align-items: center; margin-top: 2mm; }
.credencial-foto { width: 22mm !important; height: 26mm !important; max-width: 22mm !important; max-height: 26mm !important; border-radius: 4px; border: 1px solid #ddd; object-fit: cover; }
.credencial-info { font-size: 7.5pt; line-height: 1.25; flex-grow: 1; }
.credencial-info .emp-id { font-size: 9pt; font-weight: bold; color: var(--primary); }
.credencial-qr { width: 22mm; height: 22mm; }

@media print {
    body * { visibility: hidden !important; }
    #area-impresion, #area-impresion * { visibility: visible !important; }
    #area-impresion { position: absolute !important; left: 0 !important; top: 0 !important; }
}