/* VelatorioPro - Jardines del Sur */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --sidebar-w: 260px;
    --topbar-h: 56px;
    --primary: #1e5580;
    --primary-hover: #17476b;
    --primary-light: #2a6fa0;
    --primary-bg: #e8f0f8;
    --gold: #c9a84c;
    --gold-hover: #b89639;
    --gold-light: #f5ecd0;
    --sidebar-bg: #0f1b2d;
    --sidebar-hover: #1a2d47;
    --sidebar-active: #1e5580;
    --content-bg: #f5f3ef;
    --card-bg: #ffffff;
    --text-main: #1a1a2e;
    --text-muted: #6b7280;
    --border-color: #e5e1d8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
}

[data-theme="dark"] {
    --sidebar-bg: #080e18;
    --sidebar-hover: #0f1b2d;
    --content-bg: #0f1520;
    --card-bg: #1a2332;
    --text-main: #e8e4df;
    --text-muted: #8d96a0;
    --border-color: #2a3545;
    --primary-bg: #1a2d47;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--content-bg);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

/* ═══ Sidebar ═══ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 8px;
}

.sidebar-logo-emoji {
    font-size: 28px;
    line-height: 1;
}

.sidebar-brand {
    font-size: 16px;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.sidebar-brand small {
    display: block;
    font-size: 10px;
    font-weight: 400;
    color: #94a3b8;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.sidebar-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #475569;
    padding: 16px 16px 6px;
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-bottom: 2px;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: 0 2px 8px rgba(30, 85, 128, 0.3);
}

.sidebar-link i {
    font-size: 17px;
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--gold));
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.sidebar-user-name {
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 600;
}

.sidebar-user-role {
    font-size: 11px;
    color: #64748b;
}

/* ═══ Main Content ═══ */
.main-content {
    margin-left: var(--sidebar-w);
    background-color: var(--content-bg);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* ═══ Topbar ═══ */
.topbar {
    height: var(--topbar-h);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 1030;
    backdrop-filter: blur(12px);
}

.topbar-toggle {
    display: none;
    padding: 0;
    color: var(--text-muted);
}

.topbar-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-muted);
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-icon {
    color: var(--text-muted);
    font-size: 18px;
    padding: 8px;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
}

.topbar-icon:hover {
    color: var(--primary);
    background: var(--primary-bg);
}

.topbar-user {
    color: var(--text-main);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.topbar-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--gold));
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

/* ═══ Page ═══ */
.page-content {
    padding: 24px;
    flex: 1;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: var(--text-main);
}

/* ═══ Cards ═══ */
.stat-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid rgba(201, 168, 76, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle at top right, rgba(201, 168, 76, 0.05), transparent 70%);
}

.stat-card:hover {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
    transform: translateY(-4px);
    border-color: rgba(201, 168, 76, 0.3);
}

.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: rgba(30, 85, 128, 0.05);
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-top: 4px;
}

.card {
    border: none;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
    background-color: var(--card-bg);
    color: var(--text-main);
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
    font-weight: 700;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ═══ Table improvements ═══ */
.table {
    font-size: 14px;
}

.table thead th {
    background-color: rgba(30, 85, 128, 0.02);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 15px 20px;
    border-bottom: 2px solid var(--border-color);
}

.table tbody td {
    padding: 15px 20px;
    vertical-align: middle;
}

/* ═══ Login ═══ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f1b2d 0%, #1e5580 50%, #0f1b2d 100%);
    position: relative;
}

.login-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at 30% 20%, rgba(201, 168, 76, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(30, 85, 128, 0.2) 0%, transparent 50%);
}

.login-card {
    background: rgba(255, 255, 255, 0.97);
    border-radius: 24px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
    border: 1px solid rgba(201, 168, 76, 0.2);
}

.login-logo {
    text-align: center;
    margin-bottom: 8px;
}

.login-logo img {
    max-width: 200px;
    height: auto;
}

.login-title {
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 4px;
    color: var(--primary);
}

.login-subtitle {
    text-align: center;
    color: var(--gold);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 32px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ═══ Buttons ═══ */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
    border-radius: 10px;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
    box-shadow: 0 4px 12px rgba(30, 85, 128, 0.3);
}

.btn-gold {
    background: var(--gold);
    border-color: var(--gold);
    color: #fff;
    font-weight: 600;
}

.btn-gold:hover {
    background: var(--gold-hover);
    border-color: var(--gold-hover);
    color: #fff;
}

.btn {
    border-radius: 10px;
    font-weight: 500;
}

/* ═══ Badge colors ═══ */
.badge {
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.3px;
}

.bg-primary {
    background-color: var(--primary) !important;
}

/* ═══ Forms ═══ */
.form-control,
.form-select {
    border-radius: 10px;
    border-color: var(--border-color);
    font-size: 13.5px;
    transition: all 0.2s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 85, 128, 0.12);
}

.form-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
}

/* ═══ Responsive ═══ */

/* Tablet & smaller */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .topbar-toggle {
        display: block;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1035;
        display: none;
        backdrop-filter: blur(4px);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .page-header h1 {
        font-size: 18px;
    }
}

/* Phone landscape & small tablets */
@media (max-width: 768px) {
    .page-content {
        padding: 16px 12px;
    }

    .topbar {
        padding: 0 12px;
        height: 50px;
    }

    .topbar-title {
        font-size: 12px;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Cards more compact */
    .stat-card {
        padding: 16px 12px;
        border-radius: 12px;
    }

    .stat-card .stat-value {
        font-size: 22px;
    }

    .stat-card .stat-label {
        font-size: 10px;
    }

    .card {
        border-radius: 12px;
    }

    .card-header {
        padding: 14px 16px;
        font-size: 13px;
    }

    /* Tables: compact cells */
    .table thead th {
        padding: 10px 8px;
        font-size: 10px;
        letter-spacing: 0.5px;
    }

    .table tbody td {
        padding: 10px 8px;
        font-size: 13px;
    }

    /* Buttons */
    .btn-sm {
        padding: 5px 10px;
        font-size: 12px;
    }

    .btn {
        font-size: 13px;
    }

    /* Forms */
    .form-control,
    .form-select {
        font-size: 14px;
        padding: 8px 10px;
    }

    .form-label {
        font-size: 12px;
        margin-bottom: 4px;
    }

    /* Modal */
    .modal-dialog {
        margin: 8px;
    }

    /* Alert flashes */
    .alert {
        margin: 8px !important;
        font-size: 13px;
        padding: 10px 14px;
    }

    /* DataTables adjustments */
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length {
        text-align: left !important;
        margin-bottom: 8px;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
    }

    .dataTables_wrapper .dataTables_info {
        font-size: 11px;
    }

    /* Page header buttons */
    .page-header .btn {
        font-size: 12px;
        padding: 6px 12px;
    }

    /* Hide less important table columns on phones */
    .table .d-md-table-cell {
        display: none !important;
    }
}

/* Phone portrait */
@media (max-width: 576px) {
    .page-content {
        padding: 12px 8px;
    }

    .page-header h1 {
        font-size: 16px;
    }

    .page-header .badge {
        font-size: 10px;
    }

    /* Stat cards: even more compact */
    .stat-card {
        padding: 12px 8px;
    }

    .stat-card .stat-value {
        font-size: 18px;
    }

    .stat-card .stat-label {
        font-size: 9px;
        letter-spacing: 0.4px;
    }

    .stat-card .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
        border-radius: 10px;
    }

    /* Cards */
    .card-header {
        padding: 12px;
        font-size: 12.5px;
    }

    .card-body {
        padding: 12px;
    }

    /* Tables: very compact */
    .table thead th {
        padding: 8px 6px;
        font-size: 9px;
    }

    .table tbody td {
        padding: 8px 6px;
        font-size: 12px;
    }

    /* Action buttons in table: icon-only */
    .table .btn-sm {
        padding: 4px 6px;
        font-size: 11px;
    }

    .table .btn-sm .bi {
        font-size: 12px;
    }

    /* Row columns: stack on very small */
    .row.g-3 {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
    }

    /* Forms */
    .form-control,
    .form-select {
        font-size: 14px;
        border-radius: 8px;
    }

    /* Presupuesto form: items table */
    #itemsTable .form-control-sm,
    #itemsTable .form-select-sm {
        font-size: 12px;
        padding: 4px 6px;
    }

    /* Login responsive */
    .login-card {
        padding: 32px 24px;
        margin: 16px;
        border-radius: 18px;
    }

    .login-title {
        font-size: 18px;
    }

    /* Sidebar footer compact */
    .sidebar-footer {
        padding: 12px;
    }

    .sidebar-user-name {
        font-size: 12px;
    }

    .sidebar-user-role {
        font-size: 10px;
    }

    /* Calendar: smaller */
    .fc .fc-toolbar {
        flex-direction: column;
        gap: 8px;
    }

    .fc .fc-toolbar-title {
        font-size: 16px !important;
    }

    .fc .fc-button {
        padding: 4px 8px !important;
        font-size: 11px !important;
    }

    /* Topbar ultra compact */
    .topbar {
        height: 46px;
        padding: 0 8px;
    }

    .topbar-title {
        font-size: 11px;
        max-width: 90px;
    }

    .topbar-icon {
        padding: 6px;
        font-size: 16px;
    }

    .topbar-avatar {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }

    /* Dropdown menus */
    .dropdown-menu {
        font-size: 13px;
    }

    /* Badge */
    .badge {
        font-size: 10px;
        padding: 3px 6px;
    }

    /* Filters row on reports/audit */
    .d-flex.gap-2 {
        flex-wrap: wrap;
    }

    /* Tables horizontal scroll */
    .table-responsive {
        font-size: 12px;
    }
}

/* ═══ Bottom safe area for iOS ═══ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .sidebar-footer {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

/* ═══ Touch improvements ═══ */
@media (hover: none) and (pointer: coarse) {
    .sidebar-link {
        padding: 12px 16px;
        min-height: 44px;
    }

    .btn-sm {
        min-height: 36px;
        min-width: 36px;
    }

    .table tbody td {
        min-height: 44px;
    }

    .stat-card:hover {
        transform: none;
    }
}

/* ═══ DataTables ═══ */
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 6px 14px;
    font-size: 13px;
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 4px 10px;
}

/* ═══ Empty state ═══ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #9ca3af;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    color: var(--gold);
    opacity: 0.5;
}

.empty-state h5 {
    color: var(--text-muted);
}

/* ═══ Animations ═══ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-card,
.card {
    animation: fadeInUp 0.4s ease both;
}

.row .col-6:nth-child(2) .stat-card,
.row .col-lg-3:nth-child(2) .stat-card {
    animation-delay: 0.05s;
}

.row .col-6:nth-child(3) .stat-card,
.row .col-lg-3:nth-child(3) .stat-card {
    animation-delay: 0.1s;
}

.row .col-6:nth-child(4) .stat-card,
.row .col-lg-3:nth-child(4) .stat-card {
    animation-delay: 0.15s;
}

/* ═══ Scrollbar ═══ */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* ═══ WhatsApp ═══ */
.btn-whatsapp {
    background: #25D366;
    color: #fff;
    border: none;
}

.btn-whatsapp:hover {
    background: #1da851;
    color: #fff;
}

/* ═══ Velatorio status indicator ═══ */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-dot.en_curso {
    background: var(--primary);
    box-shadow: 0 0 6px rgba(30, 85, 128, 0.5);
    animation: pulse 2s infinite;
}

.status-dot.programado {
    background: #3b82f6;
}

.status-dot.finalizado {
    background: var(--success);
}

.status-dot.disponible {
    background: var(--success);
}

.status-dot.ocupada {
    background: var(--danger);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ═══ Photo thumb ═══ */
.foto-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 10px;
}