/* ===========================
   SISTEMA DE TEMAS (LIGHT/DARK)
   =========================== */

:root {
    /* Colores base - tema claro */
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --bg-card-border: #e5e7eb;
    --bg-header: #0f172a;
    --bg-header-alt: #111827;

    --text-main: #111827;
    --text-muted: #6b7280;
    --text-on-header: #f9fafb;

    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.08);

    --table-header-bg: #e5e7eb;
    --table-row-alt: #f9fafb;

    --input-bg: #ffffff;
    --input-border: #d1d5db;
}

/* Tema oscuro */
:root[data-theme="dark"] {
    --bg-body: #020617;
    --bg-card: #0b1120;
    --bg-card-border: #1f2937;
    --bg-header: #020617;
    --bg-header-alt: #020617;

    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --text-on-header: #e5e7eb;

    --accent: #38bdf8;
    --accent-soft: rgba(56, 189, 248, 0.12);

    --table-header-bg: #111827;
    --table-row-alt: #020617;

    --input-bg: #020617;
    --input-border: #374151;
}

/* ===========================
   BASE / GLOBAL
   =========================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 0;
}

/* Contenedor principal de la app */
.container {
    max-width: 1200px;
    margin: 80px auto 40px auto; /* deja aire arriba para la barra */
    padding: 0 20px 20px 20px;
    background: transparent;
}

/* Títulos generales */
h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

h2 {
    font-size: 1.3rem;
    margin: 1.5rem 0 0.5rem 0;
    color: var(--text-main);
}

/* Texto introductorio debajo del título principal */
.container > p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* ===========================
   TOPBAR / HEADER / MENÚ SUPERIOR
   =========================== */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    background: var(--bg-header);
    color: var(--text-on-header);
    padding: 10px 16px;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.3);
}

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

.brand-logo {
    height: 40px;
    width: auto;
}

.brand-title {
    font-size: 20px;
    font-weight: bold;
    color: var(--text-on-header);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar a {
    color: var(--text-on-header);
    text-decoration: none;
    margin-left: 10px;
    font-size: 0.9rem;
    font-weight: 500;
}

.topbar a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.user-greeting {
    color: var(--text-on-header);
    font-size: 0.9rem;
}

/* Menú horizontal simple */
.menu {
    margin-bottom: 15px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.35);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.menu a {
    margin-right: 15px;
    text-decoration: none;
    color: var(--accent);
    font-size: 14px;
    font-weight: 500;
}

.menu a:hover {
    text-decoration: underline;
}

/* ===========================
   BOTÓN CAMBIO DE TEMA
   =========================== */

.theme-toggle-btn {
    border: none;
    background: transparent;
    color: var(--text-on-header);
    cursor: pointer;
    font-size: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    transition: background-color 0.2s ease, transform 0.15s ease;
    margin-left: 8px;
}

.theme-toggle-btn:hover {
    background-color: rgba(148, 163, 184, 0.25);
    transform: translateY(-1px);
}

.theme-toggle-btn:active {
    transform: scale(0.95);
}

/* ===========================
   FORMULARIOS / INPUTS
   =========================== */

form {
    margin-top: 15px;
}

label {
    display: block;
    margin-top: 10px;
    font-weight: bold;
    color: var(--text-main);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    padding: 8px;
    margin-top: 4px;
    box-sizing: border-box;
    border-radius: 4px;
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-main);
    font-size: 0.9rem;
}

textarea {
    min-height: 80px;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

/* Grilla de formulario de 2 columnas (ordenruta, procesoruta, etc.) */
.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px 18px;
}

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

.form-group-full {
    grid-column: 1 / -1;
}

.form-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ===========================
   BOTONES
   =========================== */

.btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 6px;
    border: none;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.85rem;
    background: #2563eb;
    color: #fff;
    font-weight: 600;
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.1s ease;
}

.btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.4);
}

.btn-sm {
    padding: 4px 8px;
    font-size: 0.8rem;
}

.btn-secondary {
    background: #6b7280;
}

.btn-secondary:hover {
    background: #4b5563;
}

/* ===========================
   MENSAJES (ALERTAS)
   =========================== */

.mensaje,
.alert {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.mensaje.ok,
.alert-success {
    background: #d4edda;
    color: #155724;
}

.mensaje.error,
.alert-error {
    background: #f8d7da;
    color: #721c24;
}

/* ===========================
   LOGIN
   =========================== */

.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f6f7f8 0%, #eef2f3 100%);
}

.login-container {
    max-width: 400px;
    width: 100%;
    background: #fff;
    padding: 25px 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.login-logo img {
    height: 60px;
}

.login-title {
    text-align: center;
    margin-top: 5px;
    margin-bottom: 15px;
    font-size: 20px;
    font-weight: bold;
    color: #333;
}

/* ===========================
   MENÚ PRINCIPAL (tarjetas)
   =========================== */

.main-menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.menu-card {
    position: relative;
    background: var(--bg-card);
    border-radius: 14px;
    padding: 15px;
    text-align: center;
    text-decoration: none;
    color: var(--text-main);
    border: 1px solid var(--bg-card-border);
    transition: all 0.25s ease-in-out;
    transform: translateY(0);
    cursor: pointer;
    overflow: hidden;
}

.menu-card-icon {
    font-size: 26px;
    margin-bottom: 8px;
    color: var(--accent);
    transition: all 0.2s ease-in-out;
}

.menu-card-title {
    font-weight: bold;
    margin-bottom: 5px;
}

.menu-card-desc {
    font-size: 13px;
    color: var(--text-muted);
}

/* Efecto hover moderno */
.main-menu-grid .menu-card:hover {
    transform: translateY(-6px) scale(1.03);
    background: #ffffff;
    box-shadow: 0px 12px 28px rgba(0, 0, 0, 0.15);
}

.main-menu-grid .menu-card:hover .menu-card-icon {
    transform: scale(1.15) rotate(5deg);
}

/* Borde de brillo alrededor */
.main-menu-grid .menu-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 14px;
    padding: 0;
    pointer-events: none;
}

.main-menu-grid .menu-card:hover::after {
    padding: 2px;
    background: linear-gradient(135deg, #1e90ff, #00c9a7, #ffb74d);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

/* ===========================
   CARDS GENERALES (Dashboard, formularios, tablas)
   =========================== */

.card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    border: 1px solid var(--bg-card-border);
    margin-bottom: 18px;
    color: var(--text-main);
}

.card-header {
    font-weight: 600;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--bg-card-border);
    padding-bottom: 6px;
    color: var(--text-main);
    background: linear-gradient(
        135deg,
        rgba(37, 99, 235, 0.06),
        rgba(56, 189, 248, 0.06)
    );
}

.card-body {
    overflow-x: auto;
}

/* Grilla de cards (dashboard, etc.) */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* KPIs del Dashboard */
.kpi-card {
    text-align: left;
    padding-left: 12px;
}

.kpi-card .card-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.kpi-number {
    font-size: 2.1rem;
    font-weight: 700;
    margin-top: 4px;
    color: var(--text-main);
}

.kpi-total { border-left: 4px solid #3b82f6; }
.kpi-proceso { border-left: 4px solid #f59e0b; }
.kpi-terminadas { border-left: 4px solid #10b981; }
.kpi-canceladas { border-left: 4px solid #ef4444; }

/* ===========================
   TABLAS (data-table y table)
   =========================== */

.table,
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    background-color: transparent;
    color: var(--text-main);
}

.table th,
.table td,
.data-table th,
.data-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: middle;
}

.table thead th,
.data-table thead th {
    background: var(--table-header-bg);
    font-weight: 600;
    color: var(--text-main);
    position: sticky;
    top: 0;
    z-index: 1;
}

.table-hover tbody tr:hover,
.data-table tbody tr:hover {
    background: #f3f4f6;
}

/* Alternancia de filas para data-table (ya usamos table-row-alt del tema) */
.data-table tbody tr:nth-child(even) {
    background-color: var(--table-row-alt);
}

/* ===========================
   FORMULARIO DE FILTROS
   =========================== */

.filter-form .form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.filter-form .form-group {
    min-width: 160px;
    display: flex;
    flex-direction: column;
}

.filter-form label {
    font-size: 0.8rem;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.filter-form select,
.filter-form input[type="date"],
.filter-form input[type="text"] {
    padding: 5px 8px;
    border-radius: 6px;
    border: 1px solid var(--input-border);
    font-size: 0.85rem;
    color: var(--text-main);
    background-color: var(--input-bg);
}

/* ===========================
   BADGES DE STATUS
   =========================== */

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-pendiente {
    background: #fef3c7;
    color: #92400e;
}

.status-proceso {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-terminado {
    background: #dcfce7;
    color: #166534;
}

.status-cancelado {
    background: #fee2e2;
    color: #b91c1c;
}

/* ===========================
   TEXTOS SECUNDARIOS
   =========================== */

.page-header p,
.menu-card-desc,
.field-help,
.text-muted,
.small-text {
    color: var(--text-muted);
}

/* ===========================
   RESPONSIVE - TABLET / CELULAR
   =========================== */

/* Hasta 992px (tablets) */
@media (max-width: 992px) {
    .container {
        margin-top: 70px;
        padding: 0 16px 16px 16px;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }

    .main-menu-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

/* Hasta 768px (tablets chicas / móviles grandes) */
@media (max-width: 768px) {
    .container {
        margin-top: 70px;
        padding: 0 12px 16px 12px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        border-radius: 0 0 10px 10px;
    }

    .topbar-right {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .menu {
        border-bottom: none;
        padding-top: 6px;
        padding-bottom: 6px;
        overflow-x: auto;
        white-space: nowrap;
    }

    .menu a {
        margin-right: 8px;
        padding: 4px 10px;
        border-radius: 999px;
        background-color: rgba(148, 163, 184, 0.12);
        white-space: nowrap;
    }

    .main-menu-grid {
        grid-template-columns: 1fr 1fr;
    }

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

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .table thead th,
    .data-table thead th {
        font-size: 0.8rem;
    }

    .table td,
    .data-table td {
        font-size: 0.78rem;
    }
}

/* Hasta 480px (móviles chicos) */
@media (max-width: 480px) {
    body {
        font-size: 0.9rem;
    }

    .container {
        margin-top: 60px;
        padding: 0 10px 14px 10px;
    }

    .brand-title {
        font-size: 1rem;
    }

    .menu {
        margin-bottom: 10px;
    }

    .main-menu-grid {
        grid-template-columns: 1fr;
    }

    .menu-card {
        padding: 12px;
    }

    .kpi-number {
        font-size: 1.8rem;
    }

    .btn {
        width: auto;
    }
}

/* Extra pequeño < 360px, por si acaso */
@media (max-width: 360px) {
    .topbar {
        padding: 8px 10px;
    }

    .brand-title {
        font-size: 0.95rem;
    }

    .menu a {
        font-size: 12px;
        padding: 3px 8px;
    }
}




