@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&family=Outfit:wght@400;600;800&display=swap');

:root {
    --primary: #0f172a;
    --primary-light: #1e293b;
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --success: #10b981;
    --error: #ef4444;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* --- Layout & Navbar --- */
nav {
    background: var(--primary);
    padding: 1.25rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

nav h1 {
    font-size: 1.5rem;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

nav h1 span {
    color: var(--accent);
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: white;
}

.nav-logo img {
    height: 40px;
    width: auto;
    border-radius: 4px;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.nav-links a:hover {
    color: white;
}

.btn-admin {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-admin:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Hero Section --- */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    padding: 5rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('https://www.transparenttextures.com/patterns/cubes.png');
    opacity: 0.05;
}

.hero h2 {
    font-size: 3rem;
    margin-bottom: 1.5rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.hero p {
    font-size: 1.2rem;
    color: #94a3b8;
    max-width: 600px;
    margin: 0 auto 2.5rem;
}

/* --- Search Box --- */
.search-container {
    max-width: 600px;
    margin: -3rem auto 0;
    padding: 0 1rem;
    position: relative;
    z-index: 10;
}

.search-box {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    gap: 1rem;
    border: 1px solid var(--border);
}

input {
    flex: 1;
    padding: 0.875rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

button {
    padding: 0.875rem 2rem;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-whatsapp {
    background: var(--success);
    color: white;
    width: 100%;
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.btn-whatsapp:hover {
    background: #0ea271;
    filter: brightness(1.1);
}

.btn-whatsapp-header {
    background: #25D366;
    color: white;
    margin-left: 1rem;
}

.btn-whatsapp-header:hover {
    background: #128c7e;
}

/* --- Result Card --- */
.result-card {
    margin-top: 2rem;
    padding: 2rem;
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: none;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.status-badge {
    padding: 0.5rem 1rem;
    border-radius: 99px;
    font-size: 0.875rem;
    font-weight: 600;
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fef3c7;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.info-item label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.info-item span {
    font-weight: 600;
    color: var(--text-main);
}

.wide-form {
    max-width: 900px !important;
}

.form-section {
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

.form-section h3 {
    margin-bottom: 1.25rem;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 0.5rem;
}

.section-sender {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.section-recipient {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.section-cargo {
    background: #fff7ed;
    border-color: #ffedd5;
}

.section-sender h3 {
    color: #166534;
}

.section-cargo h3 {
    color: #9a3412;
}

.info-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}

.input-with-search {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    padding: 0.5rem;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon.whatsapp {
    background: #25D366;
}

.btn-icon.whatsapp:hover {
    background: #128c7e;
}

textarea {
    width: 100%;
    padding: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    resize: vertical;
}

.total-field {
    background: #fffbeb;
    font-weight: 800;
    font-size: 1.1rem;
    color: #92400e;
}

/* --- Admin / Login Pages --- */
.admin-view {
    padding: 4rem 2rem;
}

.form-container {
    max-width: 500px;
    margin: 0 auto;
    background: white;
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-container h2 {
    margin-bottom: 2rem;
    text-align: center;
    font-size: 1.75rem;
}

.error-message {
    background: #fef2f2;
    color: var(--error);
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-size: 0.9rem;
    border: 1px solid #fee2e2;
    display: none;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.checkbox-group input {
    width: auto;
    cursor: pointer;
}

.checkbox-group label {
    margin-bottom: 0 !important;
    cursor: pointer;
    font-weight: 500 !important;
    color: var(--text-muted);
}

.success-message {
    background: #ecfdf5;
    color: var(--success);
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-size: 0.9rem;
    border: 1px solid #d1fae5;
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .hero h2 {
        font-size: 2.25rem;
    }

    .search-box {
        flex-direction: column;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    nav {
        padding: 1rem;
    }
}

/* Botones de Acción (Estilo Imagen) */
.action-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 220px;
}

.btn-action {
    padding: 1.25rem 1rem;
    border-radius: 12px;
    border: 3px solid #ef4444;
    /* Borde rojo por defecto como en la imagen */
    font-weight: 900;
    text-align: center;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 1.1rem;
    color: #000;
    transition: transform 0.2s, background-color 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    width: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.btn-action span {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: none;
    margin-top: 0.25rem;
}

.btn-action:hover {
    transform: translateY(-2px);
    opacity: 0.9;
}

.btn-action:active {
    transform: translateY(0);
}

.btn-buscar-r {
    background-color: #fcd34d;
}

/* Amarillo */
.btn-nuevo-c {
    background-color: #6ee7b7;
}

/* Verde */
.btn-registrar {
    background-color: #94a3b8;
}

/* Gris/Azul */
.btn-buscar-d {
    background-color: #fb923c;
}

/* Naranja */
.btn-nuevo-a {
    background-color: #ca8a04;
}

/* Goldenrod */
.btn-imprimir {
    background-color: #ff0000;
    color: white !important;
    border-color: #cbd5e1;
}

/* Rojo */

.admin-layout-wrapper {
    display: flex;
    gap: 2rem;
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
    align-items: flex-start;
}

.admin-view {
    padding: 0;
}

@media (max-width: 1024px) {
    .admin-layout-wrapper {
        flex-direction: column-reverse;
    }

    .action-sidebar {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

/* --- Menú Hamburguesa y Navegación Móvil --- */
.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    gap: 5px;
}

.hamburger span {
    width: 25px;
    height: 3px;
    background-color: white;
    border-radius: 2px;
    transition: all 0.3s;
}

@media (max-width: 768px) {
    nav {
        position: relative;
    }

    .hamburger {
        display: flex;
    }

    .nav-links {
        display: none;
        /* Oculto por defecto */
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: var(--primary);
        padding: 1.5rem 0;
        box-shadow: var(--shadow-lg);
        z-index: 1000;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }

    .nav-links.active {
        display: flex;
        /* Visible al activar */
    }

    /* Ajustes globales para móviles */
    .info-grid-3 {
        grid-template-columns: 1fr;
        /* Apilar columnas de 3 en 1 */
    }

    .form-container {
        padding: 1.5rem;
        /* Reducir padding en móviles */
    }

    .admin-view {
        padding: 1rem;
    }
}

/* Estilos para impresión */
@media print {
    .no-print {
        display: none !important;
    }
}

.print-btn {
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

/* --- Estilos Historial --- */
.historial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.historial-actions {
    display: flex;
    gap: 10px;
}

.historial-actions button {
    margin: 0;
}

.btn-secondary {
    background: #64748b;
}

.btn-teal {
    background: #0f766e;
}

.btn-danger {
    background: #ef4444;
}

.historial-filter {
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.historial-filter input {
    width: 20px;
    height: 20px;
}

.historial-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.historial-table th {
    background: #f1f5f9;
    text-align: left;
    padding: 10px;
}

/* --- Adaptación Móvil Historial --- */
@media (max-width: 768px) {
    .historial-header {
        flex-direction: column;
        align-items: stretch;
    }

    .historial-actions {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
    }

    .historial-actions button {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
    }

    .historial-table thead {
        display: none;
    }

    .historial-table,
    .historial-table tbody,
    .historial-table tr,
    .historial-table td {
        display: block;
        width: 100%;
    }

    .historial-table tr {
        margin-bottom: 1rem;
        background: white;
        border: 1px solid var(--border);
        border-radius: 8px;
        box-shadow: var(--shadow);
    }

    .historial-table td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border-bottom: 1px solid #eee;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .historial-table td::before {
        content: attr(data-label);
        font-weight: bold;
        color: var(--text-muted);
        text-align: left;
    }

    .historial-table td:last-child {
        justify-content: center;
        padding: 1rem;
        border-bottom: none;
        background: #f8fafc;
        border-radius: 0 0 8px 8px;
    }

    .historial-table td:last-child::before {
        display: none;
    }
}

/* --- Mejoras para móviles muy pequeños (< 480px) --- */
@media (max-width: 480px) {

    .container,
    .admin-view {
        padding: 0.5rem;
    }

    .form-container {
        padding: 1rem;
        border-radius: 12px;
    }

    .hero h2 {
        font-size: 1.75rem;
    }

    .search-box {
        padding: 1rem;
    }

    .btn-action {
        padding: 1rem 0.5rem;
        font-size: 1rem;
    }

    .logo-area img {
        height: 25px;
        /* Albarán logo más pequeño */
    }

    .historial-actions button {
        padding: 0.5rem 0.25rem;
        font-size: 0.7rem;
    }

    /* Asegurar que el modal/links del nav no se salgan */
    .nav-links {
        width: 100%;
        left: 0;
        right: 0;
        padding: 1rem;
    }
}