/* =========================================================
   GMJ Loreto — Fluid Premium Design System
   Architecture: Mobile-First • Full Fluid • Progressive UI
   Unified Frontend + Admin Dashboard
========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {

    /* ========= COLORS ========= */

    --primary: #000000;
    --accent: #0a3ca7;
    --accent-dark: #003496;

    --white: #ffffff;

    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;

    /* ========= TYPOGRAPHY ========= */

    --font-sans: 'Inter', system-ui, sans-serif;

    --text-xs: clamp(0.72rem, 0.68rem + 0.2vw, 0.82rem);
    --text-sm: clamp(0.82rem, 0.76rem + 0.3vw, 0.95rem);
    --text-base: clamp(0.94rem, 0.88rem + 0.35vw, 1rem);
    --text-lg: clamp(1rem, 0.96rem + 0.5vw, 1.15rem);
    --text-xl: clamp(1.25rem, 1.1rem + 0.9vw, 1.5rem);
    --text-2xl: clamp(1.7rem, 1.45rem + 1.6vw, 2.4rem);
    --text-3xl: clamp(2.3rem, 2rem + 2vw, 3.2rem);

    /* ========= SPACING ========= */

    --space-1: clamp(0.4rem, 0.35rem + 0.3vw, 0.6rem);
    --space-2: clamp(0.65rem, 0.55rem + 0.5vw, 0.9rem);
    --space-3: clamp(1rem, 0.8rem + 0.7vw, 1.3rem);
    --space-4: clamp(1.3rem, 1rem + 1vw, 1.7rem);
    --space-5: clamp(1.8rem, 1.4rem + 1.4vw, 2.5rem);
    --space-6: clamp(2.5rem, 2rem + 2vw, 4rem);

    /* ========= RADIUS ========= */

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --radius-xl: 28px;

    /* ========= SHADOWS ========= */

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 8px 20px rgba(0,0,0,0.06);
    --shadow-lg: 0 16px 40px rgba(0,0,0,0.08);

    /* ========= TRANSITIONS ========= */

    --transition:
        transform 300ms cubic-bezier(0.4,0,0.2,1),
        opacity 300ms cubic-bezier(0.4,0,0.2,1),
        background-color 300ms cubic-bezier(0.4,0,0.2,1),
        border-color 300ms cubic-bezier(0.4,0,0.2,1);

}

/* =========================================================
   RESET
========================================================= */

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

html,
body {
    width: 100%;
    overflow-x: clip;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    font-family: var(--font-sans);
    background: var(--white);
    color: var(--gray-900);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Admin Dashboard Background */
body.admin-dashboard {
    background:
        radial-gradient(circle at top left,
        rgba(10,60,167,0.05),
        transparent 35%),
        var(--gray-50);
}

img,
svg,
video,
canvas {
    display: block;
    max-width: 100%;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    border: none;
    background: none;
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

/* =========================================================
   LAYOUT
========================================================= */

.container {
    width: min(100% - 2rem, 1200px);
    margin-inline: auto;
}

.section {
    padding-block: var(--space-6);
}

.section-title {
    position: relative;
    display: inline-block;
    font-size: var(--text-2xl);
    font-weight: 800;
    letter-spacing: -0.05em;
    margin-bottom: var(--space-4);
}

.section-title::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -10px;
    width: 54px;
    height: 4px;
    border-radius: 999px;
    background: var(--accent);
}

/* =========================================================
   NAVBAR
========================================================= */

.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: 72px;
    background: rgba(255,255,255,0.82);
    border-bottom: 1px solid var(--gray-100);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

@supports not ((backdrop-filter: blur(10px))) {
    .navbar {
        background: rgba(255,255,255,0.97);
    }
}

.nav-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    min-width: 0;
}

.logo {
    font-size: var(--text-lg);
    font-weight: 800;
}

.logo span {
    color: var(--accent);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.nav-links a {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--gray-500);
}

.nav-links a.active {
    color: var(--primary);
}

/* =========================================================
   BUTTONS
========================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.95rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 700;
    transition: var(--transition);
}

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

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

.btn-outline {
    border: 1px solid var(--gray-200);
    color: var(--gray-700);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (hover:hover) {
    .btn:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: var(--shadow-md);
    }
}

.btn:active:not(:disabled) {
    transform: scale(0.985);
}

@media (min-width: 768px) {
    .btn {
        width: auto;
    }
}

/* =========================================================
   FORMS
========================================================= */

.form-card {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    box-shadow: var(--shadow-lg);
}

.form-group {
    width: 100%;
    text-align: left;
    margin-bottom: var(--space-4);
}

.form-group label {
    display: block;
    margin-bottom: 0.55rem;
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input {
    width: 100%;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    background: var(--gray-50);
    padding: 1rem 1.1rem;
    font-size: var(--text-base);
    outline: none;
    transition: var(--transition);
}

input:focus {
    background: var(--white);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(10,60,167,0.1);
}

/* =========================================================
   STATS
========================================================= */

.stats {
    display: grid;
    gap: var(--space-3);
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: var(--space-5);
}

.stat-item {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-value {
    font-size: var(--text-xl);
    font-weight: 800;
}

/* =========================================================
   SEARCH
========================================================= */

.search-container {
    margin-bottom: var(--space-5);
}

/* =========================================================
   RAFFLE GRID
========================================================= */

.raffle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(72px, 100%), 1fr));
    gap: 0.6rem;
    margin-bottom: var(--space-6);
}

.number-card {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    background: var(--white);
    font-size: var(--text-base);
    font-weight: 700;
    transition: var(--transition);
    will-change: transform;
}

.number-card.available {
    color: var(--primary);
}

@media (hover:hover) {
    .number-card.available:hover {
        border-color: var(--accent);
        transform: translateY(-1px);
        box-shadow: var(--shadow-md);
    }
}

.number-card.pending {
    background: #fef08a;
    border-color: #fde047;
    color: #854d0e;
    cursor: not-allowed;
}

.number-card.paid {
    background: var(--success);
    border-color: var(--success);
    color: var(--white);
    cursor: not-allowed;
}

.number-card.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--white);
    transform: scale(1.03);
}

/* =========================================================
   SELECTION BAR
========================================================= */

.selection-bar {
    position: fixed;
    left: 50%;
    bottom: 0.5rem;
    transform: translateX(-50%) translateY(120%);
    width: min(100% - 1rem, 800px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--radius-xl);
    background: var(--primary);
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.selection-bar.active {
    transform: translateX(-50%) translateY(0);
}

.selection-info {
    display: flex;
    justify-content: space-between;
    min-width: 0;
    color: var(--white);
    font-size: var(--text-sm);
    font-weight: 600;
}

.selection-info span {
    color: var(--success);
    font-weight: 800;
}

@media (min-width: 768px) {
    .selection-bar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 1.5rem;
    }

    .selection-info {
        gap: 2rem;
    }
}

/* =========================================================
   PAYMENT
========================================================= */

.payment-card {
    width: min(100% - 1rem, 600px);
    margin: var(--space-6) auto;
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-xl);
    padding: clamp(1.8rem, 4vw, 4rem) clamp(1.3rem, 3vw, 3rem);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.payment-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    min-width: 0;
}

.qr-placeholder {
    width: 180px;
    height: 180px;
    margin-inline: auto;
    padding: 1rem;
    border-radius: var(--radius-lg);
    background: var(--white);
    border: 1px solid var(--gray-100);
    box-shadow: var(--shadow-sm);
}

.pix-qr-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.pix-code {
    width: 100%;
    max-width: 400px;
    margin: 1rem auto 1.5rem;
    padding: 1.2rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    background: var(--gray-50);
    font-family: monospace;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--accent);
    word-break: break-all;
}

.pix-instructions-box {
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    background: rgba(10,60,167,0.03);
    border: 1px solid rgba(10,60,167,0.1);
    text-align: left;
}

.pix-instructions-box p {
    margin-bottom: 1rem;
    font-size: var(--text-base);
    font-weight: 800;
    color: var(--accent);
}

.pix-instructions-box ol {
    padding-left: 1.3rem;
    font-size: var(--text-sm);
}

.pix-instructions-box li {
    margin-bottom: 0.7rem;
    line-height: 1.4;
}

/* =========================================================
   MODALS
========================================================= */

.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0,0,0,0.5);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 300ms ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    max-height: min(90vh, 900px);
    overflow-y: auto;
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: var(--transition);
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-sm {
    max-width: 400px;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* =========================================================
   TOASTS
========================================================= */

#toast-container {
    position: fixed;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 1rem 1.2rem;
    background: var(--white);
    border-left: 5px solid var(--accent);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    opacity: 0;
    transform: translateY(-10px);
    transition: var(--transition);
}

.toast.active {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--error);
}

@media (min-width: 768px) {
    #toast-container {
        left: auto;
        width: 360px;
    }
}

/* =========================================================
   ADMIN
========================================================= */

.admin-login {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 120px);
    margin-top: var(--space-6);
}

.admin-login .form-card {
    width: 100%;
    max-width: 460px;
}

.admin-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 1rem;
    margin-bottom: var(--space-5);
    border-bottom: 1px solid var(--gray-100);
}

.admin-content {
    margin-top: var(--space-5);
}

.admin-list {
    display: grid;
    gap: 1rem;
}

.admin-item {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
    padding: 1.4rem;
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

@media (min-width: 768px) {
    .admin-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .admin-item {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* Enhanced Admin Styles for Dashboard */
body.admin-dashboard .form-card {
    background: rgba(255,255,255,0.88);
    border: 1px solid rgba(255,255,255,0.7);
    backdrop-filter: blur(14px);
}

body.admin-dashboard .stat-item {
    position: relative;
    overflow: hidden;
    background: rgba(255,255,255,0.9);
    border: 1px solid rgba(255,255,255,0.8);
    backdrop-filter: blur(10px);
}

body.admin-dashboard .stat-item::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(10,60,167,0.05), transparent);
    pointer-events: none;
}

body.admin-dashboard .admin-item {
    background: rgba(255,255,255,0.88);
    border: 1px solid rgba(255,255,255,0.7);
    backdrop-filter: blur(10px);
}

body.admin-dashboard .admin-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* =========================================================
   CHART CARD
========================================================= */

canvas {
    width: 100% !important;
}

.p-2 {
    padding: 1.5rem !important;
}

/* =========================================================
   UTILITIES
========================================================= */

.hidden {
    display: none !important;
}

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

.w-auto {
    width: auto !important;
}

.mx-auto {
    margin-inline: auto !important;
}

.flex {
    display: flex !important;
}

.flex-1 {
    flex: 1;
}

.gap-1 {
    gap: 1rem !important;
}

.text-center {
    text-align: center !important;
}

.text-success {
    color: var(--success) !important;
}

.text-accent {
    color: var(--accent) !important;
}

.text-muted {
    color: var(--gray-500) !important;
}

.font-800 {
    font-weight: 800 !important;
}

.text-4xl {
    font-size: var(--text-3xl) !important;
}

.mt-1 {
    margin-top: 1rem !important;
}

.mt-2 {
    margin-top: 2rem !important;
}

.mt-3 {
    margin-top: 3rem !important;
}

.mt-4 {
    margin-top: 4rem !important;
}

.mt-5 {
    margin-top: 5rem !important;
}

.mb-05 {
    margin-bottom: 0.5rem !important;
}

.mb-1 {
    margin-bottom: 1rem !important;
}

.mb-15 {
    margin-bottom: 1.5rem !important;
}

.mb-2 {
    margin-bottom: 2rem !important;
}

.mb-25 {
    margin-bottom: 2.5rem !important;
}

.mb-3 {
    margin-bottom: 3rem !important;
}

.order-summary-box {
    margin-block: 1.5rem;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    background: var(--gray-50);
    text-align: left;
}

.section-header-accent {
    border-left: 5px solid var(--accent);
    padding-left: 1rem;
}

.section-header-success { border-left: 5px solid var(--success); padding-left: 1rem; }

/* Chart Container Stability */
.chart-container {
    position: relative;
    width: 100%;
    height: clamp(250px, 35vh, 350px); /* Stable height for mobile & PC */
    margin-top: 1rem;
}