:root {
    --red-primary: #570101;
    --red-dark: #3d0101;
    --red-light: #750202;
    --red-pale: #f8eded;
    --white: #FFFFFF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-400: #9CA3AF;
    --gray-600: #4B5563;
    --gray-800: #1F2937;
    --shadow: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
    --radius: 12px;
    --radius-sm: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Josefin Sans', system-ui, sans-serif;
    background: #BF290B;
    color: var(--gray-800);
    min-height: 100vh;
    line-height: 1.6;
}

body.has-sidebar {
    overflow-x: hidden;
}

/* Sidebar layout */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--red-primary);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 200;
    box-shadow: var(--shadow-lg);
}

.sidebar-brand {
    padding: 1.5rem 1.25rem 1rem;
    font-weight: 700;
    font-size: 1.15rem;
    border-bottom: 1px solid rgba(255,255,255,.12);
}

.sidebar-close {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    opacity: .85;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    padding: 0 .75rem;
}

.sidebar-menu a {
    display: block;
    color: rgba(255,255,255,.88);
    text-decoration: none;
    padding: .7rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 500;
    transition: background .2s, color .2s;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: rgba(255,255,255,.15);
    color: var(--white);
}

.sidebar-footer {
    padding: 1rem 1.25rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.12);
}

.sidebar-user-name {
    font-size: .85rem;
    margin-bottom: .65rem;
    opacity: .9;
    word-break: break-word;
}

.sidebar-footer .btn-logout {
    display: block;
    text-align: center;
    background: rgba(255,255,255,.18);
    color: var(--white);
    text-decoration: none;
    padding: .5rem .75rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    font-weight: 500;
    transition: background .2s;
}

.sidebar-footer .btn-logout:hover {
    background: rgba(255,255,255,.28);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 150;
}

.app-main {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: calc(100% - 260px);
}

.mobile-topbar {
    display: none;
    align-items: center;
    gap: 1rem;
    padding: .85rem 1rem;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 50;
}

.mobile-topbar-title {
    font-weight: 600;
    font-size: .95rem;
}

.sidebar-toggle {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.sidebar-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--red-primary);
    border-radius: 2px;
}

/* Legacy navbar - removed */
.navbar { display: none; }

.nav-brand,
.brand-icon,
.nav-toggle,
.nav-menu,
.nav-user {
    display: none;
}

/* Main */
.main-content {
    flex: 1;
    padding: 2rem 1.5rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    background-image: var(--login-bg-image);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    padding: 1.5rem;
}

.login-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
    max-width: 420px;
}

.login-copyright {
    font-size: .85rem;
    color: var(--gray-600);
    text-align: center;
    margin: 0;
    font-weight: 500;
}

.login-page.has-custom-bg {
    background-color: var(--white);
    background-blend-mode: normal;
}

/* Login layout: imagen a la izquierda, formulario a la derecha */
.login-layout {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    background-image: var(--login-bg-image);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.login-image {
    flex: 1;
    background-image: var(--login-bg-image);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: var(--white);
}

.login-panel {
    width: 440px;
    max-width: 100%;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
    border: 1px solid var(--gray-200);
}

.login-logo {
    max-height: 90px;
    max-width: 220px;
    object-fit: contain;
    margin-bottom: 1rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.login-demo-hint {
    margin-top: 1.25rem;
    text-align: center;
    font-size: .8rem;
    color: #9CA3AF;
}

.password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field input {
    padding-right: 2.75rem;
}

.password-toggle {
    position: absolute;
    right: .5rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: .35rem .5rem;
    font-size: 1.1rem;
    line-height: 1;
    opacity: .65;
    transition: opacity .2s;
}

.password-toggle:hover {
    opacity: 1;
}

.config-preview {
    margin-bottom: .75rem;
    padding: .75rem;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
}

.config-preview-logo {
    max-height: 70px;
    max-width: 180px;
    object-fit: contain;
    display: block;
    margin-bottom: .5rem;
}

.config-preview-bg {
    max-height: 100px;
    width: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
    display: block;
    margin-bottom: .5rem;
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .875rem;
    cursor: pointer;
}

.field-hint {
    font-size: .75rem;
    color: var(--gray-400);
    margin-top: .25rem;
}

/* Dashboard search & summary */
.dashboard-search-card {
    margin-bottom: 1.75rem;
}

.dashboard-search-form .search-label {
    font-weight: 600;
    font-size: .95rem;
    margin-bottom: .5rem;
    display: block;
}

.dashboard-search-row {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
}

.dashboard-search-row input {
    flex: 1;
    min-width: 220px;
}

.search-empty {
    margin-top: 1rem;
    color: var(--gray-600);
    font-size: .9rem;
}

.search-results {
    margin-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.search-result-item {
    display: block;
    padding: .85rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: inherit;
    transition: border-color .2s, background .2s;
}

.search-result-item:hover {
    border-color: var(--red-primary);
    background: var(--red-pale);
}

.search-result-meta {
    font-size: .8rem;
    color: var(--gray-600);
    margin-top: .25rem;
}

.dashboard-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card .card-body {
    padding: 1.25rem 1.5rem;
}

.last-inscrito {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.last-inscrito-photo {
    width: 100px;
    height: 100px;
    border-radius: var(--radius);
    object-fit: cover;
    border: 3px solid var(--red-pale);
    flex-shrink: 0;
}

.last-inscrito-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--red-pale);
    font-size: 2.5rem;
}

.last-inscrito-info h3 {
    font-size: 1.2rem;
    margin-bottom: .35rem;
}

.last-inscrito-info .meta {
    font-size: .85rem;
    color: var(--gray-600);
    margin-top: .2rem;
}

.last-inscrito-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-top: .75rem;
}

.payments-highlight {
    text-align: center;
    padding: 1.25rem;
    background: var(--red-pale);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.payments-highlight-label {
    display: block;
    font-size: .85rem;
    color: var(--gray-600);
    margin-bottom: .25rem;
}

.payments-highlight-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--red-primary);
}

.payments-stats-list {
    list-style: none;
}

.payments-stats-list li {
    display: flex;
    justify-content: space-between;
    padding: .6rem 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: .9rem;
}

.payments-stats-list li:last-child {
    border-bottom: none;
}

.login-header {
    background: var(--red-primary);
    color: var(--white);
    padding: 2rem;
    text-align: center;
}

.login-header h1 { font-size: 1.5rem; margin-bottom: .25rem; }
.login-header p { opacity: .85; font-size: .9rem; }

.login-body { padding: 2rem; }

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    background: var(--red-primary);
    color: var(--white);
    padding: 1.25rem 1.5rem;
}

.card-header h2 { font-size: 1.2rem; font-weight: 600; }
.card-header p { opacity: .85; font-size: .875rem; margin-top: .25rem; }

.card-body { padding: 1.5rem; }

/* Page header */
.page-header {
    margin-bottom: 1.75rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-800);
}

.page-header p {
    color: var(--gray-600);
    margin-top: .25rem;
}

.link-back {
    color: var(--red-primary);
    text-decoration: none;
    font-weight: 500;
}

.link-back:hover {
    text-decoration: underline;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
}

.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group.full-width { grid-column: 1 / -1; }

label {
    font-size: .875rem;
    font-weight: 500;
    color: var(--gray-600);
}

label .required { color: var(--red-primary); }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="file"],
select,
textarea {
    padding: .65rem .85rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: .925rem;
    font-family: inherit;
    transition: border-color .2s, box-shadow .2s;
    background: var(--white);
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--red-primary);
    box-shadow: 0 0 0 3px rgba(87, 1, 1, .15);
}

textarea { resize: vertical; min-height: 80px; }

/* Image preview */
.image-upload-area {
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    position: relative;
}

.image-upload-area:hover,
.image-upload-area.dragover {
    border-color: var(--red-primary);
    background: var(--red-pale);
}

.image-upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.image-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius-sm);
    margin-top: 1rem;
    object-fit: cover;
}

.upload-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.upload-text { color: var(--gray-600); font-size: .875rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .65rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: .925rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background .2s, transform .1s, box-shadow .2s;
    text-decoration: none;
}

.btn:active { transform: scale(.98); }

.btn-primary {
    background: var(--red-primary);
    color: var(--white);
}

.btn-primary:hover { background: var(--red-dark); }

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-800);
}

.btn-secondary:hover { background: var(--gray-200); }

.btn-danger {
    background: #DC2626;
    color: var(--white);
}

.btn-sm { padding: .4rem .85rem; font-size: .8rem; }

.btn-excel {
    background: #217346;
    color: var(--white);
}

.btn-excel:hover {
    background: #1a5c38;
}

.card-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-actions {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-100);
}

/* Alerts */
.alert {
    padding: .85rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-size: .9rem;
    font-weight: 500;
}

.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-error { background: var(--red-pale); color: var(--red-dark); border: 1px solid #FECACA; }
.alert-info { background: #DBEAFE; color: #1E40AF; border: 1px solid #BFDBFE; }

/* Dashboard stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--red-primary);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--red-primary);
}

.stat-card .stat-label {
    font-size: .875rem;
    color: var(--gray-600);
    margin-top: .25rem;
}

/* Quick actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.action-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: transform .2s, box-shadow .2s;
    border: 2px solid transparent;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--red-pale);
}

.action-card .action-icon {
    font-size: 2rem;
    margin-bottom: .75rem;
}

.action-card h3 { font-size: 1rem; margin-bottom: .25rem; }
.action-card p { font-size: .825rem; color: var(--gray-600); }

/* Tables */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

thead { background: var(--red-primary); color: var(--white); }

th, td {
    padding: .75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

tbody tr:hover { background: var(--red-pale); }

.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}

.badge-red { background: var(--red-pale); color: var(--red-dark); }
.badge-green { background: #D1FAE5; color: #065F46; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* Search bar */
.search-bar {
    display: flex;
    gap: .75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.search-bar input,
.search-bar select {
    flex: 1;
    min-width: 180px;
}

/* Hidden fields */
.hidden { display: none !important; }

/* Participant detail */
.participant-header {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.participant-photo {
    width: 120px;
    height: 120px;
    border-radius: var(--radius);
    object-fit: cover;
    border: 3px solid var(--red-pale);
}

.participant-info h2 { font-size: 1.4rem; }
.participant-info .meta { color: var(--gray-600); font-size: .875rem; margin-top: .25rem; }

.participant-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.card-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card-danger-zone .card-header {
    background: #7f1d1d;
}

.danger-hint {
    font-size: .875rem;
    color: var(--gray-600);
    margin-bottom: 1rem;
}

.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    align-items: center;
}

.form-inline {
    display: inline-flex;
}

.form-cambiar-grupo {
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-wrap: wrap;
}

.form-cambiar-grupo .select-sm {
    padding: .4rem .5rem;
    font-size: .8rem;
    min-width: 130px;
    max-width: 160px;
}

.participant-info-only h2 {
    font-size: 1.4rem;
    margin-bottom: .35rem;
}

.participant-info-only .meta {
    color: var(--gray-600);
    font-size: .875rem;
    margin-top: .2rem;
}

.backup-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
}

/* Payment summary */
.payment-types {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.payment-type-option input { display: none; }

.payment-type-option label {
    display: block;
    padding: .85rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    text-align: center;
    cursor: pointer;
    font-weight: 500;
    font-size: .85rem;
    transition: all .2s;
}

.payment-type-option input:checked + label {
    border-color: var(--red-primary);
    background: var(--red-pale);
    color: var(--red-dark);
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.25rem;
    color: var(--gray-400);
    font-size: .8rem;
    border-top: 1px solid var(--gray-100);
}

/* Uppercase UI (menú y títulos) */
.sidebar-menu a,
.sidebar-brand .brand-text,
.page-header h1,
.mobile-topbar-title {
    text-transform: uppercase;
}

/* También en encabezados de tarjetas */
.card-header h2,
.card-header h3 {
    text-transform: uppercase;
}

.login-header h1 {
    text-transform: uppercase;
}

/* Responsive */
@media (max-width: 768px) {
    .login-layout {
        flex-direction: column;
    }

    .login-image {
        height: 220px;
        flex: none;
    }

    .login-panel {
        width: 100%;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform .3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: block;
    }

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

    .app-main {
        margin-left: 0;
        width: 100%;
    }

    .mobile-topbar {
        display: flex;
    }

    .main-content { padding: 1.25rem 1rem; }

    .page-header h1 { font-size: 1.4rem; }

    th, td { padding: .6rem .75rem; }
}

@media (max-width: 480px) {
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; }
    .login-body { padding: 1.5rem; }
}
