/* ============================================= */
/* Finca Joya — Custom CSS                       */
/* Mobile-first responsive design                */
/* ============================================= */

:root {
    --fj-primary: #2d6a4f;
    --fj-primary-dark: #1b4332;
    --fj-primary-light: #40916c;
    --fj-accent: #52b788;
    --fj-accent-light: #95d5b2;
    --fj-bg: #f0f4f0;
    --fj-card-bg: #ffffff;
    --fj-text: #1a1a2e;
    --fj-text-muted: #6c757d;
    --fj-border: #dee2e6;
    --fj-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --fj-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --fj-radius: 12px;
    --fj-radius-sm: 8px;
    --fj-bottom-nav-h: 64px;
    --fj-top-nav-h: 56px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--fj-bg);
    color: var(--fj-text);
    padding-top: var(--fj-top-nav-h);
    padding-bottom: calc(var(--fj-bottom-nav-h) + 16px);
    padding-bottom: calc(var(--fj-bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 16px);
    min-height: 100vh;
}

/* ============================================= */
/* Top Navbar                                    */
/* ============================================= */
.navbar-main {
    background: linear-gradient(135deg, var(--fj-primary-dark), var(--fj-primary));
    height: var(--fj-top-nav-h);
    padding: 0 12px;
    box-shadow: var(--fj-shadow);
    z-index: 1030;
}

.navbar-main .navbar-brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.navbar-main .navbar-brand:hover {
    color: var(--fj-accent-light);
}

.user-badge {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ============================================= */
/* Main Content                                  */
/* ============================================= */
.main-content {
    padding-top: 16px;
    padding-bottom: 16px;
}

/* ============================================= */
/* Bottom Navigation                             */
/* ============================================= */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--fj-bottom-nav-h);
    height: calc(var(--fj-bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: 0px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--fj-card-bg);
    border-top: 1px solid var(--fj-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1050;
    /* Superiores a validaciones */
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--fj-text-muted);
    font-size: 0.65rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: var(--fj-radius-sm);
    transition: all 0.2s;
    min-width: 56px;
}

.bottom-nav-item i {
    font-size: 1.25rem;
    margin-bottom: 2px;
}

.bottom-nav-item.active {
    color: var(--fj-primary);
    font-weight: 700;
}

.bottom-nav-item:hover {
    color: var(--fj-primary);
}

.bottom-nav-main-icon {
    font-size: 1.75rem !important;
    color: var(--fj-primary);
}

/* ============================================= */
/* Cards & Lists                                 */
/* ============================================= */
.card-fj {
    background: var(--fj-card-bg);
    border: none;
    border-radius: var(--fj-radius);
    box-shadow: var(--fj-shadow);
    margin-bottom: 12px;
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
}

.card-fj:hover {
    transform: translateY(-1px);
    box-shadow: var(--fj-shadow-lg);
}

.card-fj .card-body {
    padding: 14px 16px;
}

.card-fj .card-header-fj {
    background: linear-gradient(135deg, var(--fj-primary), var(--fj-primary-light));
    color: #fff;
    padding: 12px 16px;
    font-weight: 600;
    font-size: 0.95rem;
}

.stat-card {
    text-align: center;
    padding: 16px;
}

.stat-card .stat-icon {
    font-size: 2rem;
    margin-bottom: 6px;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--fj-primary-dark);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.78rem;
    color: var(--fj-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Item cards for list views */
.item-card {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    text-decoration: none;
    color: var(--fj-text);
    border-bottom: 1px solid var(--fj-border);
}

.item-card:last-child {
    border-bottom: none;
}

.item-card:hover {
    background: rgba(45, 106, 79, 0.04);
}

.item-card .item-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--fj-accent-light), var(--fj-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.item-card .item-info {
    flex: 1;
    min-width: 0;
}

.item-card .item-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin: 0;
}

.item-card .item-sub {
    font-size: 0.8rem;
    color: var(--fj-text-muted);
    margin: 0;
}

.item-card .item-amount {
    font-weight: 700;
    font-size: 1rem;
    text-align: right;
    white-space: nowrap;
}

/* ============================================= */
/* Page Headers                                  */
/* ============================================= */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.page-header h1 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--fj-primary-dark);
    margin: 0;
}

/* ============================================= */
/* Buttons                                       */
/* ============================================= */
.btn-fj {
    background: linear-gradient(135deg, var(--fj-primary), var(--fj-primary-light));
    color: #fff;
    border: none;
    border-radius: var(--fj-radius-sm);
    padding: 10px 20px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-fj:hover {
    background: linear-gradient(135deg, var(--fj-primary-dark), var(--fj-primary));
    color: #fff;
    transform: translateY(-1px);
}

.btn-fj-outline {
    background: transparent;
    color: var(--fj-primary);
    border: 2px solid var(--fj-primary);
    border-radius: var(--fj-radius-sm);
    padding: 8px 18px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-fj-outline:hover {
    background: var(--fj-primary);
    color: #fff;
}

.btn-fj-danger {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    color: #fff;
    border: none;
    border-radius: var(--fj-radius-sm);
    padding: 10px 20px;
    font-weight: 600;
}

.btn-fj-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.fab-btn {
    position: fixed;
    bottom: calc(var(--fj-bottom-nav-h) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--fj-primary), var(--fj-accent));
    color: #fff;
    border: none;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--fj-shadow-lg);
    z-index: 1020;
    transition: transform 0.2s;
    text-decoration: none;
}

.fab-btn:hover {
    transform: scale(1.1);
    color: #fff;
}

/* ============================================= */
/* Forms                                         */
/* ============================================= */
.form-fj .form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--fj-text);
    margin-bottom: 4px;
}

.form-fj .form-control,
.form-fj .form-select {
    border-radius: var(--fj-radius-sm);
    border: 1.5px solid var(--fj-border);
    padding: 10px 14px;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-fj .form-control:focus,
.form-fj .form-select:focus {
    border-color: var(--fj-accent);
    box-shadow: 0 0 0 3px rgba(82, 183, 136, 0.15);
}

.form-fj .input-group-text {
    background: var(--fj-bg);
    border: 1.5px solid var(--fj-border);
    border-radius: var(--fj-radius-sm);
    font-weight: 600;
    color: var(--fj-primary);
}

/* ============================================= */
/* Badges                                        */
/* ============================================= */
.badge-activo {
    background: #d4edda;
    color: #155724;
    font-weight: 600;
}

.badge-inactivo {
    background: #f8d7da;
    color: #721c24;
    font-weight: 600;
}

.badge-pagado {
    background: #cce5ff;
    color: #004085;
    font-weight: 600;
}

.badge-cancelado {
    background: #fff3cd;
    color: #856404;
    font-weight: 600;
}

.badge-prestamo {
    background: #e2e3f1;
    color: #383d6e;
    font-weight: 600;
}

.badge-adelanto {
    background: #fde8d0;
    color: #7c4a03;
    font-weight: 600;
}

/* ============================================= */
/* Tables (for reports)                          */
/* ============================================= */
.table-fj {
    font-size: 0.85rem;
    border-radius: var(--fj-radius);
    overflow: hidden;
}

.table-fj thead th {
    background: var(--fj-primary);
    color: #fff;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    padding: 10px 12px;
}

.table-fj tbody td {
    padding: 10px 12px;
    vertical-align: middle;
    border-color: var(--fj-border);
}

/* ============================================= */
/* Ticket / Print                                */
/* ============================================= */
.ticket-container {
    max-width: 380px;
    margin: 0 auto;
    background: #fff;
    padding: 20px;
    font-size: 0.85rem;
}

.ticket-container h2 {
    font-size: 1.1rem;
}

.ticket-container .divider {
    border-top: 1px dashed #999;
    margin: 10px 0;
}

.ticket-container .firma-line {
    border-top: 1px solid #333;
    width: 200px;
    margin: 30px auto 4px;
    text-align: center;
}

/* ============================================= */
/* Responsive helpers                            */
/* ============================================= */
.text-money {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.text-money-green {
    color: var(--fj-primary);
}

.text-money-red {
    color: #c0392b;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--fj-text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 10px;
    display: block;
}

/* Computed field (readonly display) */
.computed-field {
    background: #e8f5e9;
    border: 2px solid var(--fj-accent);
    border-radius: var(--fj-radius-sm);
    padding: 10px 14px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--fj-primary-dark);
    text-align: right;
}

/* ============================================= */
/* Login Page                                    */
/* ============================================= */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--fj-primary-dark) 0%, var(--fj-primary) 40%, var(--fj-accent) 100%);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-card .login-logo i {
    font-size: 3rem;
    color: var(--fj-primary);
}

.login-card .login-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--fj-primary-dark);
    margin: 8px 0 0;
}

/* ============================================= */
/* Print Styles                                  */
/* ============================================= */
@media print {
    body {
        padding: 0;
        background: #fff;
    }

    .navbar-main,
    .bottom-nav,
    .d-print-none,
    .fab-btn {
        display: none !important;
    }

    .main-content {
        padding: 0;
    }

    .card-fj {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ============================================= */
/* Small screen adjustments                      */
/* ============================================= */
@media (max-width: 576px) {
    .page-header h1 {
        font-size: 1.15rem;
    }

    .stat-card .stat-value {
        font-size: 1.25rem;
    }

    .btn-fj,
    .btn-fj-danger {
        width: 100%;
    }
}