:root {
    /* Primary Palette - Original Brand Colors */
    --mirage: #16232A;
    --blaze-orange: #FF5B04;
    --deep-sea-green: #075056;
    --wild-sand: #E4EEF0;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;

    --primary: var(--blaze-orange);
    --primary-light: #ff7f3f;
    --secondary: var(--deep-sea-green);

    /* Theme Variables - Default DARK */
    --bg-body: var(--mirage);
    --text-main: var(--wild-sand);
    --text-muted: #94a3b8;
    --card-bg: rgba(31, 46, 56, 0.7);
    --glass-border: rgba(228, 238, 240, 0.1);
    --sidebar-bg: #111b21;
    --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --radius-lg: 1.25rem;
    --radius-md: 0.75rem;
    --radius-sm: 0.5rem;
    --input-bg: rgba(10, 15, 20, 0.5);
    --glass-glow: rgba(7, 80, 86, 0.2);
    --reg-num-color: #cbd5e1;
    /* Color claro para fondo oscuro */
}

[data-theme="light"] {
    --bg-body: var(--wild-sand);
    --text-main: var(--mirage);
    --text-muted: #475569;
    --card-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(22, 35, 42, 0.1);
    --sidebar-bg: #ffffff;
    --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --input-bg: rgba(255, 255, 255, 0.9);
    --glass-glow: rgba(7, 80, 86, 0.05);
    --reg-num-color: #334155;
    /* Color oscuro para fondo claro */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background: var(--bg-body);
    background-image:
        radial-gradient(at 0% 0%, rgba(7, 80, 86, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(255, 91, 4, 0.1) 0px, transparent 50%);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.4s ease, color 0.4s ease;
    overflow-x: hidden;
}

/* Common Classes Unification */
.sidebar-toggle {
    display: none;
}

.glass,
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
    border-radius: var(--radius-lg);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-glow {
    box-shadow: 0 0 40px var(--glass-glow);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.text-gradient {
    color: var(--primary);
}

/* Buttons System */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 91, 4, 0.3);
    background: #e65200;
}

.btn-secondary {
    background: var(--secondary);
    color: white;
    border: none;

}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
    opacity: 0.9;
}

.btn-glass,
.btn-control {
    background: hsla(0, 0%, 100%, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    backdrop-filter: blur(8px);
}

.btn-glass:hover,
.btn-control:hover {
    background: hsla(0, 0%, 100%, 0.1);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--secondary);
    color: var(--secondary);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-outline:hover {
    background: var(--secondary);
    color: white;
    box-shadow: 0 0 15px var(--glass-glow);
}

/* Cabecera Publica / Login Responsiva */
.top-brand {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 1000;
}

.top-brand img {
    height: 38px;
    width: auto;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.2));
}

.top-center-title {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    pointer-events: none;
}

.top-center-title img {
    height: 36px;
    width: auto;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.2));
}

.top-actions {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 1000;
}

/* Tablas Responsivas */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: 0.8rem;
}

.table-responsive table {
    width: 100%;
    min-width: 600px;
    border-collapse: separate;
    border-spacing: 0 0.5rem;
}

/* Cabecera Admin Responsiva */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    gap: 1rem;
    position: relative;
    z-index: 1000;
}

.header-title-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* User Dropdown System */
.user-dropdown {
    position: relative;
}

.user-trigger {
    cursor: pointer;
    transition: all 0.3s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.user-trigger:hover {
    box-shadow: 0 0 0 2px var(--primary);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 220px;
    padding: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
}

.dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    color: var(--text-main);
    text-decoration: none;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    transition: 0.2s;
}

.dropdown-item:hover {
    background: rgba(255, 91, 4, 0.1);
    color: var(--primary);
}

.dropdown-item.text-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.dropdown-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 0.5rem 0;
}

/* Admin Layout (Sticky / Responsive) */
.admin-layout {

    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 180px;
    min-width: 180px;
    max-width: 180px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
    padding: 1.5rem 0.8rem;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* Distribuye cabecera, nav y pie */
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1100;
    overflow: hidden;
    /* Evita que salgan elementos */
}

.sidebar-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.sidebar-header h2 {
    font-size: 1.6rem;
    letter-spacing: -0.05em;
}

.main-content {
    flex: 1;
    padding: 2.5rem;
    margin-left: 180px;
    /* Espacio para el sidebar fixed a la izquierda */
    width: calc(100% - 180px);
    margin-bottom: 5rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-main);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 600;
    font-size: 0.82rem;
    /* Tamaño de letra más chico */
    opacity: 0.9;
}

.nav-link i {
    width: 16px;
    text-align: center;
    font-size: 0.9rem;
}

.nav-link.active,
.nav-link:hover {
    opacity: 1;
    background: var(--glass-glow);
    color: var(--secondary);
    transform: translateX(5px);
}

.nav-link.active {
    background: var(--secondary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

/* Grids & Cards */
.animal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.animal-card {
    transition: transform 0.4s, box-shadow 0.4s;
}

.animal-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

/* Responsive Table */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    background: var(--input-bg);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th,
td {
    padding: 1.2rem;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

/* Modals System Unification */
.modal-overlay,
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s, visibility 0.3s;
    padding: 1.5rem;
}

.modal-overlay.active,
.modal.active,
.modal-overlay.open {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.modal-content {
    width: 100%;
    max-width: 650px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.active .modal-content,
.modal-overlay.active .modal-content {
    transform: scale(1);
}

/* Modal Grids */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 2.5rem;
}

.detail-subgrid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Mobile Bottom Navigation */
.mobile-nav,
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: rgba(22, 35, 42, 0.85);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    padding: 0.75rem 0.5rem;
}

.mobile-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.mobile-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 700;
    transition: 0.3s;
}

.mobile-link.active {
    color: var(--primary);
}

/* Badges */
.badge {
    padding: 0.4rem 0.8rem;
    border-radius: 0.6rem;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Stats */
.stat-card {
    transition: 0.3s;
}

.stat-card:hover {
    rotate: 1deg;
    scale: 1.02;
    border-color: var(--primary);
}

/* Inputs Premium */
input,
select,
textarea {
    width: 100%;
    padding: 0.8rem 1.25rem;
    border-radius: var(--radius-md);
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    transition: 0.3s;
}

input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(255, 91, 4, 0.1);
}

/* --- ANIMAL CARDS PREMIUM --- */
.animal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    padding: 2rem 0;
}

.animal-card {
    cursor: pointer;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--glass-border);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    height: 100%;
}

.animal-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
    border-color: var(--primary);
}

.card-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #111;
}

.animal-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.animal-card:hover .animal-photo {
    transform: scale(1.08);
}

.status-overlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
}

.badge-con-hogar {
    background: rgba(7, 80, 86, 0.9) !important;
}

.badge-callejero {
    background: rgba(255, 91, 4, 0.9) !important;
}

.card-body {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.card-header-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.6rem;
}

.animal-name {
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.animal-reg {
    font-family: 'Outfit';
    font-weight: 900;
    font-size: 0.7rem;
    color: var(--primary);
    background: rgba(255, 91, 4, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 0.4rem;
}

.animal-meta {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 1.2rem;
    flex: 1;
    font-weight: 500;
}

.card-footer {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
}

.card-footer i {
    color: var(--secondary);
    font-size: 0.8rem;
}

.footer-text {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
    opacity: 0.9;
}

/* --- RESPONSIVE ADJUSTMENTS --- */

@media (max-width: 1024px) {
    .sidebar {
        width: 180px;
        padding: 1.5rem 0.8rem;
    }

    .main-content {
        margin-left: 180px;
        width: calc(100% - 180px);
    }

    .sidebar-header h2 span {
        display: none;
    }

    .nav-text {
        display: inline;
    }

    .nav-link {
        justify-content: center;
        padding: 1rem;
    }

    .nav-link i {
        font-size: 1.25rem;
    }

    .user-pill {
        display: none !important;
    }

    /* Admin Responsive Fixes */
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .header-title-group {
        width: 100%;
        justify-content: space-between;
    }

    .admin-form-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .admin-form-grid>div {
        grid-column: span 1 !important;
    }

    .modal-content {
        padding: 1.5rem !important;
        margin: 1rem;
        width: calc(100% - 2rem);
    }

    .glass,
    .glass-card {
        padding: 1rem !important;
    }

    /* Tabla en móvil: Ajuste de botones */
    .table-responsive table td {
        padding: 0.8rem 0.5rem !important;
    }

    .table-responsive td .btn {
        padding: 0.6rem 0.8rem !important;
        font-size: 0.8rem;
    }
}

@media (max-width: 768px) {
    .sidebar {
        /* Se oculta, el menú hamburguesa lo controla */
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        width: 180px;
        height: 100vh;
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
        z-index: 1200;
        border-right: 1px solid var(--glass-border);
        border-left: none;
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-header h2 span,
    .nav-text {
        display: inline;
    }

    .nav-link {
        justify-content: flex-start;
    }

    .user-pill {
        display: flex !important;
    }

    .main-content {
        padding: 1.5rem 1rem;
        margin-right: 0 !important;
        width: 100% !important;
        margin-bottom: 5rem;
    }

    .sidebar-toggle {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: var(--card-bg);
        border: 1px solid var(--glass-border);
        border-radius: 12px;
        color: var(--text-main);
        cursor: pointer;
    }

    .bottom-nav,
    .mobile-nav {
        display: block;
    }

    .hero-actions {
        flex-direction: row !important;
        padding: 0 0.5rem;
    }

    .hero-actions .btn {
        width: 100%;
        max-width: 320px;
        font-size: 1rem !important;
        padding: 0.8rem 1rem !important;
        border-radius: 3rem !important;
        margin-bottom: 0 !important;
    }

    /* Reducir tamaño de fuente de la cabecera */
    .hero h1 {
        font-size: 2.2rem !important;
        margin-bottom: 1rem !important;
    }

    .hero p {
        font-size: 0.95rem !important;
    }

    .search-box {
        flex-direction: row !important;
        border-radius: 3rem !important;
        padding: 0.4rem !important;
        margin: 0 0.5rem !important;
    }

    .search-box input {
        padding-left: 2.5rem !important;
        font-size: 0.9rem !important;
    }

    .search-box i.fa-search {
        left: 1rem !important;
    }

    .search-box .btn {
        width: auto !important;
        border-radius: 2.5rem !important;
        padding: 0.6rem 1.2rem !important;
    }

    .detail-grid,
    .detail-subgrid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }

    .animal-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        padding: 1.5rem;
    }

    .top-brand {
        top: 1rem;
        left: 1rem;
    }

    .top-brand img {
        height: 30px;
    }

    .top-center-title {
        top: 1rem;
    }

    .top-center-title img {
        height: 26px;
    }

    .top-actions {
        top: 1rem;
        right: 1rem;
    }

    .top-actions .btn {
        padding: 0.5rem 0.8rem !important;
        font-size: 0.85rem !important;
    }

    .top-actions .nav-text {
        display: none !important;
    }

    .theme-toggle,
    .theme-switch {
        width: 38px !important;
        height: 38px !important;
    }

    .admin-form-grid {
        grid-template-columns: 1fr !important;
    }

    .main-content {
        padding: 1.5rem !important;
    }
}

/* Utility Classes */
.flex {
    display: flex;
}

.flex-column {
    display: flex;
    flex-direction: column;
}

.justify-between {
    justify-content: space-between;
}

.align-center {
    align-items: center;
}

.gap-1 {
    gap: 1rem;
}

.gap-2 {
    gap: 2rem;
}

.p-2 {
    padding: 2rem;
}

.mb-2 {
    margin-bottom: 2rem;
}

.w-full {
    width: 100%;
}

.text-center {
    text-align: center;
}

.font-900 {
    font-weight: 900;
}

.p-1-5 {
    padding: 1.5rem;
}

.section-title {
    font-weight: 900;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.admin-body {
    background: var(--bg-body);
    overflow-x: hidden;
}


/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeInUp 0.5s ease forwards;
}



.theme-toggle,
.theme-switch {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s;
}

.theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    z-index: 9999;
    transform: translateX(120%);
    transition: 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    transform: translateX(0);
}

/* Image Zoom System */
.zoom-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: zoom-out;
}

.zoom-modal.active {
    opacity: 1;
    visibility: visible;
}

.zoom-img {
    max-width: 90%;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    border: 3px solid var(--glass-border);
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8);
    transform: scale(0.9);
    transition: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    object-fit: contain;
}

.zoom-modal.active .zoom-img {
    transform: scale(1);
}