/* ============================================
   INMOBILIARIA - SISTEMA DE SEGUIMIENTO
   Anabel Castro · Century 21 REALTOR
   Premium Dark + Gold Design System
   ============================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@400;500;600;700&display=swap');

/* ============================================
   1. CSS CUSTOM PROPERTIES
   ============================================ */
:root {
    /* Backgrounds — Cream theme */
    --bg-primary: #F5F0E8;
    --bg-secondary: #EDE7DB;
    --bg-card: #FFFFFF;

    /* Sidebar (se mantiene oscuro) */
    --sidebar-bg: #1a1a2e;
    --sidebar-bg-gradient: #0f0f1a;

    /* Gold palette */
    --gold-primary: #B8941F;
    --gold-light: #C8A951;
    --gold-subtle: #a08a3e;
    --gold-dark: #8B7518;

    /* Text (oscuro sobre fondo claro) */
    --text-primary: #2D2A26;
    --text-secondary: #6B6560;

    /* Semantic */
    --success: #1B8C4E;
    --danger: #C0392B;
    --info: #2471A3;
    --warning: #D4841A;

    /* Borders */
    --border-color: rgba(139, 117, 24, 0.18);
    --border-hover: rgba(139, 117, 24, 0.35);

    /* Fonts */
    --font-heading: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Sidebar */
    --sidebar-width: 260px;

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

/* ============================================
   2. RESET & BASE
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--gold-primary);
}

::selection {
    background-color: rgba(184, 148, 31, 0.25);
    color: var(--gold-dark);
}

::-moz-selection {
    background-color: rgba(200, 169, 81, 0.35);
    color: var(--gold-light);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--gold-primary);
    text-decoration: none;
    transition: color var(--transition-normal);
}

a:hover {
    color: var(--gold-light);
}

h1, h2, h3 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.3;
}

h4, h5, h6 {
    font-family: var(--font-body);
    font-weight: 600;
    line-height: 1.4;
}

/* ============================================
   3. LAYOUT
   ============================================ */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: #FDFBF7;
    padding: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    border-right: 1px solid rgba(139, 117, 24, 0.15);
    transition: transform var(--transition-normal);
    overflow-y: auto;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.04);
}

.sidebar-logo {
    padding: 28px 24px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(139, 117, 24, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.sidebar-logo .logo-icon {
    flex-shrink: 0;
}

.sidebar-logo .logo-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.sidebar-logo .logo-brand {
    font-family: var(--font-heading);
    color: var(--gold-dark);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 1.5px;
}

.sidebar-logo .logo-name {
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.sidebar-logo .logo-title {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-logo h2 {
    font-family: var(--font-heading);
    color: var(--gold-dark);
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    margin-bottom: 4px;
}

.sidebar-logo small {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.5px;
}

/* Sidebar footer (Cerrar Sesión) */
.sidebar-footer {
    margin-top: auto;
    padding: 20px;
    border-top: 1px solid rgba(139, 117, 24, 0.12);
}

.sidebar-footer a,
.sidebar-footer .logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--danger);
    text-decoration: none;
    border-radius: 8px;
    transition: all var(--transition-normal);
    font-size: 0.9rem;
    font-weight: 500;
}

.sidebar-footer a:hover,
.sidebar-footer .logout-btn:hover {
    background: rgba(192, 57, 43, 0.08);
    color: #a93226;
}

.sidebar-nav {
    flex-grow: 1;
    list-style: none;
    padding-top: 12px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    margin: 4px 12px;
    transition: all var(--transition-normal);
    gap: 12px;
    font-size: 0.92rem;
    font-weight: 500;
    position: relative;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: rgba(139, 117, 24, 0.08);
    color: var(--gold-dark);
}

.sidebar-nav a.active {
    background: rgba(139, 117, 24, 0.1);
    color: var(--gold-dark);
    border-left: 3px solid var(--gold-primary);
    font-weight: 600;
}

.sidebar-nav svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-nav .nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-logout {
    margin-top: auto;
    padding: 20px;
    border-top: 1px solid rgba(200, 169, 81, 0.15);
}

.sidebar-logout a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--danger);
    text-decoration: none;
    border-radius: 8px;
    transition: all var(--transition-normal);
    font-size: 0.92rem;
    font-weight: 500;
}

.sidebar-logout a:hover {
    background: rgba(231, 76, 60, 0.1);
}

/* ---------- Main Content ---------- */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 0;
    min-height: 100vh;
    flex: 1;
}

.top-bar {
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(245, 240, 232, 0.95);
}

.top-bar h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--gold-dark);
    font-weight: 600;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-bar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.content-area {
    padding: 30px;
    animation: fadeIn 0.3s ease;
}

/* ---------- Sidebar Toggle (Mobile) ---------- */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--gold-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background var(--transition-fast);
}

.sidebar-toggle:hover {
    background: rgba(200, 169, 81, 0.1);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* ============================================
   4. CARDS
   ============================================ */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.card-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: var(--gold-dark);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

/* ---------- Stats Grid ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stats-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stats-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.stats-card .stats-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stats-card .stats-info {
    flex: 1;
}

.stats-card .stats-number {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-heading);
    margin: 4px 0 8px;
    line-height: 1;
    color: var(--text-primary);
}

.stats-card .stats-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

/* Stats Card Color Variants */
.stats-card.gold .stats-icon {
    background: rgba(200, 169, 81, 0.15);
    color: var(--gold-primary);
}

.stats-card.green .stats-icon {
    background: rgba(46, 204, 113, 0.15);
    color: var(--success);
}

.stats-card.orange .stats-icon {
    background: rgba(243, 156, 18, 0.15);
    color: var(--warning);
}

.stats-card.blue .stats-icon {
    background: rgba(52, 152, 219, 0.15);
    color: var(--info);
}

.stats-card.red .stats-icon {
    background: rgba(231, 76, 60, 0.15);
    color: var(--danger);
}

/* ============================================
   5. TABLES
   ============================================ */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--gold-subtle);
    border-bottom: 2px solid var(--border-color);
    background: rgba(139, 117, 24, 0.04);
    font-weight: 600;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    vertical-align: middle;
    font-size: 0.92rem;
    color: var(--text-primary);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: rgba(139, 117, 24, 0.05);
}

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

.table .thumbnail {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
}

.table .thumbnail-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    background: rgba(139, 117, 24, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold-subtle);
    font-size: 1.2rem;
}

/* Botón de foto en tabla */
.btn-foto-preview {
    position: relative;
    display: inline-block;
    background: none;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-foto-preview:hover {
    border-color: var(--gold-primary);
    box-shadow: 0 4px 12px rgba(139, 117, 24, 0.15);
    transform: scale(1.05);
}

.btn-foto-preview .table-thumbnail {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
}

.btn-foto-preview .foto-count {
    position: absolute;
    bottom: -4px;
    right: -6px;
    background: var(--gold-primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    line-height: 1.3;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.table-thumbnail-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    background: rgba(139, 117, 24, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-ref {
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-width: 160px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table .actions-cell {
    white-space: nowrap;
}

/* ============================================
   6. BADGES
   ============================================ */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.4;
}

.badge-success {
    background: rgba(27, 140, 78, 0.12);
    color: var(--success);
}

.badge-warning {
    background: rgba(212, 132, 26, 0.12);
    color: var(--warning);
}

.badge-danger {
    background: rgba(192, 57, 43, 0.12);
    color: var(--danger);
}

.badge-info {
    background: rgba(36, 113, 163, 0.12);
    color: var(--info);
}

.badge-gold {
    background: rgba(139, 117, 24, 0.12);
    color: var(--gold-primary);
}

/* ============================================
   7. BUTTONS
   ============================================ */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    border: none;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-family: var(--font-body);
    line-height: 1.4;
}

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

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

.btn-primary {
    background: linear-gradient(135deg, #B8941F, #C8A951);
    color: #FFFFFF;
    box-shadow: 0 4px 15px rgba(139, 117, 24, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(139, 117, 24, 0.35);
    transform: translateY(-2px);
    color: #FFFFFF;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--gold-primary);
    color: var(--gold-primary);
}

.btn-secondary:hover {
    background: rgba(200, 169, 81, 0.1);
    color: var(--gold-primary);
}

.btn-danger {
    background: rgba(231, 76, 60, 0.15);
    color: var(--danger);
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.btn-danger:hover {
    background: rgba(231, 76, 60, 0.25);
    color: var(--danger);
}

.btn-success {
    background: rgba(46, 204, 113, 0.15);
    color: var(--success);
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.btn-success:hover {
    background: rgba(46, 204, 113, 0.25);
    color: var(--success);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-group {
    display: flex;
    gap: 8px;
}

.btn[disabled],
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ============================================
   8. FORMS
   ============================================ */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

/* Row layouts: filas con columnas fijas */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 4px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 4px;
}

.form-row-4 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 4px;
}

.form-section {
    margin-bottom: 28px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--gold-dark);
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(139, 117, 24, 0.15);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-section-title svg {
    color: var(--gold-primary);
    flex-shrink: 0;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: #FFFFFF;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.93rem;
    transition: all var(--transition-normal);
    font-family: var(--font-body);
}

.form-control::placeholder {
    color: rgba(107, 101, 96, 0.45);
}

.form-control:focus {
    outline: none;
    border-color: var(--gold-primary);
    box-shadow: 0 0 0 3px rgba(139, 117, 24, 0.12);
    background: #FFFFFF;
}

.form-control[readonly],
.form-readonly {
    opacity: 0.8;
    cursor: not-allowed;
    background: var(--bg-secondary);
    border-style: dashed;
}

/* Comisiones calculadas */
.comisiones-calculadas {
    background: rgba(139, 117, 24, 0.04);
    border-radius: 10px;
    padding: 16px;
    margin-top: 8px;
}

.comisiones-calculadas .form-group {
    margin-bottom: 0;
}

select.form-control {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238B7518' d='M6 8.825L0.375 3.2l1.05-1.05L6 6.725l4.575-4.575 1.05 1.05z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-color: #FFFFFF;
    cursor: pointer;
}

select.form-control option {
    background: #FFFFFF;
    color: var(--text-primary);
    padding: 8px;
}

textarea.form-control {
    min-height: 70px;
    resize: vertical;
    line-height: 1.6;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.form-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

/* File input hidden */
.file-input {
    display: none;
}

/* Responsive form rows */
@media (max-width: 900px) {
    .form-row-4 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .form-row-3 {
        grid-template-columns: 1fr;
    }
    .form-row-4 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .form-row-2 {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   9. FILTER BAR
   ============================================ */
.filter-bar {
    padding: 16px 20px;
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.filter-bar .filter-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: nowrap;
}

.filter-bar .filter-group {
    flex: 1;
    min-width: 0;
}

.filter-bar .filter-group .form-control {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.88rem;
}

.filter-bar .btn {
    flex-shrink: 0;
    padding: 10px 18px;
    white-space: nowrap;
}

.filter-bar .filter-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.filter-bar .form-control {
    width: auto;
    min-width: 120px;
}

.filter-bar .search-input {
    flex: 1;
    min-width: 140px;
}

/* ============================================
   10. PAGE HEADER
   ============================================ */
.page-header,
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h2 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-size: 1.4rem;
    font-weight: 600;
}

.page-header .page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* ============================================
   11. GALLERY
   ============================================ */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.gallery-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 1;
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
    cursor: pointer;
}

.gallery-item:hover {
    border-color: var(--gold-primary);
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-item .gallery-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(192, 57, 43, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-normal), transform var(--transition-fast);
    font-size: 0.85rem;
    text-decoration: none;
}

.gallery-item:hover .gallery-delete {
    opacity: 1;
}

.gallery-item .gallery-delete:hover {
    transform: scale(1.15);
    background: var(--danger);
}

/* ============================================
   12. UPLOAD ZONE
   ============================================ */
.upload-zone {
    border: 2px dashed rgba(139, 117, 24, 0.25);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    background: rgba(139, 117, 24, 0.02);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--gold-primary);
    background: rgba(139, 117, 24, 0.06);
    box-shadow: 0 0 20px rgba(139, 117, 24, 0.08);
}

.upload-zone p {
    color: var(--text-secondary);
    margin-top: 8px;
    font-size: 0.92rem;
}

.upload-zone .upload-icon {
    font-size: 2.5rem;
    color: var(--gold-subtle);
    margin-bottom: 8px;
}

.upload-zone .upload-text-main {
    color: var(--gold-dark);
    font-weight: 600;
    font-size: 1rem;
}

.upload-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    justify-content: center;
}

.upload-preview-item {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.upload-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Aviso de fotos (guardar primero) */
.foto-aviso {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(139, 117, 24, 0.06);
    border: 1px dashed rgba(139, 117, 24, 0.25);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 0.93rem;
}

/* ============================================
   LIGHTBOX
   ============================================ */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-content {
    max-width: 85vw;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: lightboxIn 0.25s ease;
    object-fit: contain;
}

@keyframes lightboxIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    z-index: 10;
}

.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-counter {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 2px;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 16px;
    border-radius: 20px;
}

/* Utility classes */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.text-small { font-size: 0.82rem; }
.text-secondary { color: var(--text-secondary); }

/* ============================================
   DETAIL VIEW (ver.php)
   ============================================ */
.detail-group {
    margin-bottom: 14px;
}

.detail-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.detail-value {
    display: block;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
    padding: 8px 12px;
    background: rgba(139, 117, 24, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    min-height: 38px;
    word-break: break-word;
}

.detail-value:empty::after {
    content: '—';
    color: var(--text-secondary);
    opacity: 0.5;
}

.detail-value .badge {
    margin-top: 0;
}

/* Action buttons row */
.action-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
}

/* ============================================
   13. FLASH MESSAGES
   ============================================ */
.flash-message {
    padding: 14px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease;
    font-size: 0.92rem;
    font-weight: 500;
    position: relative;
}

.flash-message.success {
    background: rgba(46, 204, 113, 0.15);
    border: 1px solid rgba(46, 204, 113, 0.3);
    color: var(--success);
}

.flash-message.error {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid rgba(231, 76, 60, 0.3);
    color: var(--danger);
}

.flash-message.warning {
    background: rgba(243, 156, 18, 0.15);
    border: 1px solid rgba(243, 156, 18, 0.3);
    color: var(--warning);
}

.flash-message.info {
    background: rgba(52, 152, 219, 0.15);
    border: 1px solid rgba(52, 152, 219, 0.3);
    color: var(--info);
}

.flash-message .flash-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    font-size: 1.1rem;
    padding: 0 4px;
    transition: opacity var(--transition-fast);
}

.flash-message .flash-close:hover {
    opacity: 1;
}

.flash-message.fade-out {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* ============================================
   14. PAGINATION
   ============================================ */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: 8px;
    text-decoration: none;
    transition: all var(--transition-normal);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
}

.pagination a:hover {
    border-color: var(--gold-primary);
    color: var(--gold-primary);
    background: rgba(200, 169, 81, 0.08);
}

.pagination .active {
    background: linear-gradient(135deg, #B8941F, #C8A951);
    color: #FFFFFF;
    border-color: var(--gold-primary);
    font-weight: 600;
}

.pagination .disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================
   15. LOGIN PAGE
   ============================================ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(139, 117, 24, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 117, 24, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(139, 117, 24, 0.03) 0%, transparent 50%);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.5s ease;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo h1 {
    font-family: var(--font-heading);
    color: var(--gold-dark);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.login-logo .logo-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #B8941F, #C8A951);
    color: #FFFFFF;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 16px;
    box-shadow: 0 8px 25px rgba(139, 117, 24, 0.25);
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.login-logo h2 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.login-error {
    background: rgba(192, 57, 43, 0.1);
    color: var(--danger);
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    border: 1px solid rgba(192, 57, 43, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form .form-group label {
    color: var(--text-secondary);
}

.login-form .form-control {
    padding: 14px 16px;
    font-size: 1rem;
    background: var(--bg-secondary);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.login-form .form-control:focus {
    background: #FFFFFF;
}

.login-form .btn-primary {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    margin-top: 8px;
    justify-content: center;
}

/* ============================================
   16. EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    color: var(--gold-subtle);
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.1rem;
    line-height: 1.6;
}

.empty-state .btn {
    margin-top: 20px;
}

/* ============================================
   17. CONFIRM MODAL
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #FFFFFF;
    border-radius: 16px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    border: 1px solid var(--border-color);
    text-align: center;
    animation: slideDown 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal .modal-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.modal h3 {
    margin-bottom: 12px;
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-size: 1.25rem;
}

.modal p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.modal .btn-group {
    justify-content: center;
}

/* ============================================
   18. DETAIL VIEW
   ============================================ */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.detail-item {
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.detail-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
    margin-bottom: 4px;
}

.detail-value {
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
}

.detail-value.gold {
    color: var(--gold-primary);
    font-family: var(--font-heading);
    font-size: 1.15rem;
}

/* ============================================
   19. UTILITY CLASSES
   ============================================ */
.text-gold { color: var(--gold-primary); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-small { font-size: 0.85rem; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.w-100 { width: 100%; }
.hidden { display: none !important; }

/* ============================================
   20. ANIMATIONS
   ============================================ */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease;
}

.animate-slide-down {
    animation: slideDown 0.3s ease;
}

/* ============================================
   21. CUSTOM SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: rgba(139, 117, 24, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 117, 24, 0.35);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(139, 117, 24, 0.2) var(--bg-primary);
}

/* ============================================
   22. RESPONSIVE
   ============================================ */

/* Tablets & small desktops */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .content-area {
        padding: 16px;
    }

    .top-bar {
        padding: 14px 16px;
    }

    .top-bar h1 {
        font-size: 1.2rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-bar .filter-form {
        flex-wrap: wrap;
    }

    .filter-bar .filter-group {
        flex: 1 1 100%;
        min-width: 100%;
    }
    
    .filter-bar .btn {
        width: 100%;
        justify-content: center;
    }

    .filter-bar .form-control {
        width: 100%;
        min-width: unset;
    }

    .filter-bar .search-input {
        min-width: unset;
    }

    .table {
        font-size: 0.85rem;
    }

    .table thead th {
        padding: 10px 12px;
        font-size: 0.72rem;
    }

    .table tbody td {
        padding: 10px 12px;
    }

    .btn-group {
        flex-wrap: wrap;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        justify-content: center;
    }
    
    /* Tablas Verticales */
    .table thead {
        display: none;
    }

    .table, .table tbody, .table tr, .table td {
        display: block;
        width: 100%;
    }

    .table tr {
        margin-bottom: 15px;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 10px;
        background: #fff;
    }

    .table td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border-bottom: 1px solid rgba(0,0,0,0.05);
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    .table td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.8rem;
    }

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

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .modal {
        width: 95%;
        padding: 24px;
    }

    .login-card {
        padding: 28px 24px;
    }

    .login-logo h1 {
        font-size: 1.6rem;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .stats-card .stats-number {
        font-size: 1.6rem;
    }

    .stats-card {
        padding: 18px;
    }

    .card {
        padding: 18px;
    }

    .upload-zone {
        padding: 28px 16px;
    }

    .pagination a,
    .pagination span {
        padding: 6px 10px;
        font-size: 0.82rem;
        min-width: 32px;
    }

    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .content-header .btn {
        width: 100%;
        justify-content: center;
    }

    .action-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .action-buttons {
        flex-direction: row;
        justify-content: flex-start;
        margin-top: 5px;
    }

    .action-buttons {
        flex-direction: row;
        justify-content: flex-start;
        margin-top: 5px;
    }
}

/* ============================================
   23. PRINT STYLES
   ============================================ */
@media print {
    .sidebar,
    .sidebar-overlay,
    .sidebar-toggle,
    .top-bar,
    .btn,
    .filter-bar,
    .pagination,
    .gallery-delete,
    .flash-message,
    .modal-overlay {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }

    body {
        background: white;
        color: #333;
    }

    .card,
    .stats-card,
    .table-container {
        border: 1px solid #ddd;
        background: white;
        backdrop-filter: none;
    }

    .table thead th {
        color: #333;
        background: #f5f5f5;
    }
}
