/* ==========================================================================
   AgroApp — Estilos profesionales para gestión agropecuaria
   Tema: verde campo + acentos dorados, tipografía Poppins (títulos) / Inter (texto)
   Totalmente responsive (móvil, tablet, desktop).
   ========================================================================== */

:root {
    /* Paleta principal */
    --agro-900: #12301f;
    --agro-800: #1c4a2f;
    --agro-700: #24603d;
    --agro-600: #2f7d4f;
    --agro-500: #3e945f;
    --grove-300: #9cc5a3;
    --gold-500: #c8a454;
    --gold-600: #b18a36;
    --soil-700: #7a5a2e;

    --bg-light: #f4f6ef;
    --bg-card: #ffffff;
    --ink: #26332b;
    --ink-soft: #5c6b60;
    --line: #dce3d4;

    --radius: 16px;
    --radius-sm: 9px;
    --shadow: 0 10px 30px rgba(28, 74, 47, 0.10);
    --shadow-lg: 0 18px 50px rgba(18, 48, 31, 0.16);

    --navbar-h: 64px;
}

* {
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--navbar-h) + 12px);
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-light);
    background-image:
        radial-gradient(circle at 12% -5%, rgba(62, 148, 95, 0.08) 0, transparent 38%),
        radial-gradient(circle at 95% 8%, rgba(200, 164, 84, 0.07) 0, transparent 32%);
    background-attachment: fixed;
    color: var(--ink);
    font-size: 1rem;
    line-height: 1.6;
    min-height: 100vh;
    padding-top: var(--navbar-h);
}

/* ---------- Tipografía ---------- */
h1, h2, h3, h4, h5, h6,
.display-4, .display-6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: 'Poppins', 'Inter', sans-serif;
    color: var(--agro-800);
    font-weight: 700;
    letter-spacing: 0.2px;
    line-height: 1.2;
}

.lead {
    font-weight: 500;
}

a {
    color: var(--agro-600);
    transition: color .15s ease;
}

a:hover {
    color: var(--agro-800);
}

.text-muted {
    color: var(--ink-soft) !important;
}

/* ---------- Navbar ---------- */
.app-navbar {
    background: linear-gradient(90deg, var(--agro-900) 0%, var(--agro-700) 55%, var(--agro-600) 100%);
    box-shadow: 0 6px 24px rgba(18, 48, 31, 0.28);
    min-height: var(--navbar-h);
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    z-index: 1050;
}

.app-navbar .navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: 0.4px;
    color: #fff;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
    color: #fff;
    font-size: 1.05rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}

.app-navbar .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.92);
    font-weight: 600;
    letter-spacing: 0.2px;
    padding: 0.55rem 0.9rem;
    border-radius: 9px;
    position: relative;
    transition: color .15s ease, background .15s ease;
}

.app-navbar .navbar-nav .nav-link:hover,
.app-navbar .navbar-nav .nav-link:focus {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.app-navbar .navbar-nav .nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
}

.app-navbar .dropdown-menu {
    border: none;
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 0.45rem;
    margin-top: 0.55rem;
}

.app-navbar .dropdown-item {
    border-radius: 9px;
    padding: 0.55rem 0.9rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--ink);
}

.app-navbar .dropdown-item:hover {
    background: rgba(47, 125, 79, 0.1);
    color: var(--agro-700);
}

.app-navbar .dropdown-item.text-danger:hover {
    background: rgba(200, 60, 60, 0.08);
}

.app-navbar .navbar-toggler {
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 10px;
}

.app-navbar .navbar-toggler:focus {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}

/* ---------- Contenido principal ---------- */
.app-main {
    min-height: calc(100vh - var(--navbar-h) - 70px);
}

.container {
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

/* ---------- Botones ---------- */
.btn {
    font-weight: 600;
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius-sm);
    letter-spacing: 0.2px;
    transition: transform .12s ease, box-shadow .18s ease, background .18s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--agro-700), var(--agro-600));
    border: none;
    color: #fff;
    box-shadow: 0 6px 18px rgba(28, 74, 47, 0.28);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--agro-800), var(--agro-700));
    color: #fff;
    box-shadow: 0 8px 24px rgba(28, 74, 47, 0.36);
}

.btn-success {
    background: linear-gradient(135deg, #2e7d45, var(--agro-500));
    border: none;
    color: #fff;
    box-shadow: 0 6px 18px rgba(46, 125, 69, 0.25);
}

.btn-success:hover {
    color: #fff;
    filter: brightness(1.05);
}

.btn-outline-secondary {
    border-color: var(--grove-300);
    color: var(--agro-700);
}

.btn-outline-secondary:hover {
    background: var(--grove-300);
    border-color: var(--grove-300);
    color: var(--agro-900);
}

/* ---------- Cards ---------- */
.card {
    border: 1px solid var(--line);
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: box-shadow .2s ease, transform .2s ease;
}

.card-hover:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.card .card-title {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    color: var(--agro-800);
}

.card-body {
    padding: 1.5rem;
}

.card-header {
    background: linear-gradient(90deg, var(--agro-800), var(--agro-600));
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    letter-spacing: 0.3px;
    border-bottom: none;
    padding: 0.85rem 1.25rem;
    border-radius: calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0 0;
}

.card-header .btn {
    width: auto;
    margin: 0;
}

.empty-state {
    background: #eef4ea;
    border: 1px dashed var(--grove-300);
    color: var(--agro-700);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 500;
}

/* ---------- Formularios ---------- */
.form-control,
.form-select {
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.9rem;
    background-color: #fbfcf8;
    transition: border .15s ease, box-shadow .15s ease, background .15s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--agro-500);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(62, 148, 95, 0.16);
}

.form-label {
    font-weight: 700;
    color: var(--agro-800);
    margin-bottom: 0.35rem;
}

.form-check-input:checked {
    background-color: var(--agro-600);
    border-color: var(--agro-600);
}

.input-group-text {
    background: #f2f6ee;
    border: 1.5px solid var(--line);
    color: var(--agro-700);
}

/* ---------- Tablas ---------- */
.table-responsive {
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    background: #fff;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--grove-300) transparent;
}

.table {
    --th-bg: linear-gradient(90deg, var(--agro-800), var(--agro-600));
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0;
    vertical-align: middle;
    overflow: hidden;
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 4;
    background: var(--th-bg);
    color: #fff;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    border-bottom: 2px solid rgba(255, 255, 255, 0.22);
    border-top: none;
    border-left: none;
    border-right: none;
    padding: 0.9rem 1rem;
    white-space: nowrap;
}

.table thead th:first-child {
    border-top-left-radius: var(--radius);
}

.table thead th:last-child {
    border-top-right-radius: var(--radius);
}

.table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    vertical-align: middle;
}

.table tbody tr {
    transition: background-color .15s ease;
}

.table tbody tr:nth-of-type(even) td {
    background: #f8faf4;
}

.table tbody tr:hover td {
    background: #eef4ea;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

/* Apilar: nada, pero en mobile una fila no se ve "quebrada" */
.table td.text-end,
.table td.text-start {
    font-variant-numeric: tabular-nums;
}

/* Filas con resaltado especial (sin clasificar en conciliación) */
tr.is-pending td {
    background: #fdf7e9 !important;
}

tr.is-pending:hover td {
    background: #faf0d8 !important;
}

/* Delimitar el contenedor de scroll de la tabla */
.table-responsive .table:last-child {
    padding-bottom: 0;
}

/* ---------- Badges ---------- */
.badge {
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 0.45em 0.7em;
    border-radius: 999px;
}

.badge:empty {
    display: none;
}

.badge.bg-info {
    background: rgba(58, 143, 201, 0.14) !important;
    color: #2b6f9e !important;
}

.badge.bg-success {
    background: rgba(46, 125, 69, 0.14) !important;
    color: #2e7d45 !important;
}

.badge.bg-danger {
    background: rgba(217, 91, 87, 0.14) !important;
    color: #a3403c !important;
}

.badge.bg-warning {
    background: rgba(224, 166, 62, 0.16) !important;
    color: #8a6020 !important;
}

/* ---------- Tablas de detalle de comprobantes ---------- */
.comprobantes-fields th {
    width: 32%;
    background: #eef4ea;
    color: var(--agro-800);
    font-weight: 700;
    border-bottom: 1px solid var(--line);
    padding: 0.7rem 1rem;
    vertical-align: middle;
}

.comprobantes-fields td {
    border-bottom: 1px solid var(--line);
}

.comprobantes-money {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

.comprobantes-items .editable-input {
    width: 100%;
    min-width: 90px;
}

.comprobantes-items .btn-del-item {
    border: none;
    background: transparent;
    color: #d95b57;
    font-size: 1.3rem;
    line-height: 1;
    padding: 0.2rem 0.5rem;
}

.comprobantes-items .btn-del-item:hover {
    color: #a3403c;
}

/* Celdas de acciones: botones pequeños alineados sin romper fila */
.td-actions {
    white-space: nowrap;
    text-align: right;
}

.td-actions .btn {
    margin: 0;
    width: auto;
}

/* ---------- Mensajes ---------- */
.messages-wrap {
    position: fixed;
    top: calc(var(--navbar-h) + 14px);
    right: 16px;
    left: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
}

.messages-wrap .app-alert {
    pointer-events: auto;
    max-width: 520px;
    margin-left: auto;
    border: none;
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    font-weight: 500;
}

.app-alert-success {
    background: #e6f4e3;
    color: #2c5e33;
    border-left: 5px solid #4c9a53;
}

.app-alert-danger {
    background: #fdeaea;
    color: #93322f;
    border-left: 5px solid #d95b57;
}

.app-alert-warning {
    background: #fdf3dd;
    color: #8a6020;
    border-left: 5px solid #e0a63e;
}

.app-alert-info {
    background: #e7f2fb;
    color: #24567e;
    border-left: 5px solid #4a8fc0;
}

/* ---------- Footer ---------- */
.app-footer {
    background: linear-gradient(90deg, var(--agro-900), var(--agro-800));
    color: rgba(255, 255, 255, 0.85);
    padding: 1.15rem 0;
    font-size: 0.95rem;
    letter-spacing: 0.2px;
    margin-top: 2rem;
}

.app-footer a {
    color: var(--grove-300);
}

/* ---------- Hero / Landing ---------- */
.hero-section {
    position: relative;
    background:
        linear-gradient(120deg, rgba(18, 48, 31, 0.82) 0%, rgba(36, 96, 61, 0.62) 60%, rgba(62, 148, 95, 0.35) 100%),
        url('/static/images/hero.png') no-repeat center center;
    background-size: cover;
    color: #fff;
    padding: clamp(3rem, 9vh, 6.5rem) 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    margin-top: 0.75rem;
}

.hero-content h1 {
    font-size: clamp(1.9rem, 5vw, 3.3rem);
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.5px;
    text-shadow: 0 3px 18px rgba(0, 0, 0, 0.35);
}

.hero-content p {
    font-size: clamp(1rem, 2.4vw, 1.25rem);
    color: rgba(255, 255, 255, 0.92);
    max-width: 720px;
    margin: 0 auto;
}

.hero-content .btn-light {
    background: var(--gold-500);
    border: none;
    color: var(--agro-900);
    font-weight: 700;
}

.hero-content .btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.feature-card {
    height: 100%;
    padding: 1.6rem 1.4rem;
    text-align: center;
}

.feature-icon {
    width: 62px;
    height: 62px;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--agro-600), var(--agro-800));
    box-shadow: 0 8px 22px rgba(28, 74, 47, 0.25);
}

/* ---------- Login ---------- */
.auth-card {
    max-width: 420px;
    margin: 4vh auto;
    border-radius: 20px;
    overflow: hidden;
}

.auth-card .auth-head {
    background: linear-gradient(120deg, var(--agro-800), var(--agro-600));
    color: #fff;
    padding: 2rem 1.5rem;
    text-align: center;
}

.auth-card .auth-head h1 {
    color: #fff;
    font-size: 1.4rem;
    margin: 0.6rem 0 0;
}

.auth-card .auth-body {
    padding: 2rem 1.75rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
    .app-navbar .navbar-collapse {
        border-top: 1px solid rgba(255, 255, 255, 0.15);
        margin-top: 0.4rem;
        padding-top: 0.4rem;
    }

    .app-navbar .navbar-nav .nav-link {
        padding: 0.65rem 0.9rem;
    }

    .app-navbar .dropdown-menu {
        border-radius: 10px;
        margin: 0.2rem 0 0.6rem 0.9rem;
        box-shadow: none;
        border-left: 3px solid var(--gold-500);
    }

    .messages-wrap {
        left: 8px;
        right: 8px;
    }

    .messages-wrap .app-alert {
        max-width: none;
    }
}

@media (max-width: 575.98px) {
    :root {
        --navbar-h: 58px;
    }

    body {
        font-size: 0.97rem;
    }

    .card-body {
        padding: 1rem;
    }

    .container {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .btn {
        width: 100%;
        margin-bottom: 0.4rem;
    }

    .btn-group .btn,
    .d-flex .btn {
        width: auto;
    }

    .table thead th {
        padding: 0.7rem 0.65rem;
        font-size: 0.72rem;
    }

    .table td {
        padding: 0.55rem 0.65rem;
        font-size: 0.9rem;
    }

    .table-responsive {
        border-radius: 12px;
    }

    .app-footer {
        text-align: center;
        padding: 1.4rem 0.75rem;
    }
}

/* ---------- Utilidades ---------- */
.text-grove {
    color: var(--agro-600);
}

.rounded-soft {
    border-radius: var(--radius);
}