/* ============================================
   OCDE - Design System (Light Theme)
   Branding: CLICK (Púrpura + Teal)
   ============================================ */

/* --- CSS Variables --- */
:root {
    /* Brand Colors */
    --purple-900: #2D0A4E;
    --purple-800: #3B0764;
    --purple-700: #4A0E78;
    --purple-600: #6B21A8;
    --purple-500: #7C3AED;
    --purple-400: #A78BFA;
    --purple-300: #C4B5FD;
    --purple-200: #DDD6FE;
    --purple-100: #EDE9FE;
    --purple-50: #F5F3FF;

    --teal-600: #059669;
    --teal-500: #00C98A;
    --teal-400: #00E5A0;
    --teal-300: #6EE7B7;
    --teal-100: #D1FAE5;
    --teal-50: #ECFDF5;

    /* Light Theme Neutrals */
    --bg-primary: #F8F7FC;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F9F8FE;
    --bg-input: #F4F3F9;
    --bg-input-focus: #FFFFFF;

    --border-subtle: #E8E5F0;
    --border-default: #D4D0E0;
    --border-focus: var(--purple-500);

    --text-primary: #1A1629;
    --text-secondary: #5C5775;
    --text-muted: #9490A6;
    --text-accent: var(--purple-700);

    /* Shadows */
    --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(74, 14, 120, 0.06);
    --shadow-md: 0 8px 30px rgba(74, 14, 120, 0.08);
    --shadow-lg: 0 16px 50px rgba(74, 14, 120, 0.1);
    --shadow-glow-purple: 0 4px 25px rgba(107, 33, 168, 0.12);

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 0% 0%, rgba(107, 33, 168, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 100%, rgba(0, 229, 160, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* --- Layout --- */
.app-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

/* --- Header --- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 2rem;
    background: #FFFFFF;
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-xs);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-brand img,
.header-brand svg {
    height: 32px;
    width: auto;
}

.header-brand h1 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.header-brand .badge {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--purple-600), var(--purple-500));
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.header-nav a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.header-nav a:hover {
    background: var(--purple-50);
    color: var(--purple-700);
}

.header-nav a.active {
    background: var(--purple-100);
    color: var(--purple-700);
    font-weight: 600;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-subtle);
}

.card-body {
    padding: 1.5rem 2rem;
}

/* --- Registration Card (optimized for speed) --- */
.register-card {
    width: 100%;
    max-width: 620px;
    box-shadow: var(--shadow-lg);
    animation: cardEntry 0.5s var(--transition-slow) forwards;
}

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

.register-card .card-header {
    text-align: center;
    padding: 1.75rem 2rem 1.25rem;
    background: linear-gradient(180deg, var(--purple-50), transparent);
}

.register-card .card-header .logo {
    height: 60px;
    width: auto;
    margin-bottom: 0.75rem;
}

.register-card .card-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--purple-800);
    letter-spacing: -0.02em;
}

.register-card .card-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

/* --- Forms (optimized for fast registration) --- */
.form-group {
    margin-bottom: 0.9rem;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.35rem;
}

.form-group input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--bg-input);
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all var(--transition-fast);
    outline: none;
}

.form-group input::placeholder {
    color: var(--text-muted);
    font-size: 0.88rem;
}

.form-group input:focus {
    border-color: var(--purple-500);
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.form-group input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-group .error-msg {
    font-size: 0.75rem;
    color: #ef4444;
    margin-top: 0.25rem;
    display: none;
}

.form-group .error-msg.visible {
    display: block;
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Two-column row */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* Section divider for optional fields */
.form-section {
    border-top: 1px dashed var(--border-subtle);
    margin: 0.5rem 0 0.9rem;
    padding-top: 0.75rem;
}

.form-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.6rem;
}

/* Phone input with country code prefix */
.phone-input-wrapper {
    display: flex;
    align-items: stretch;
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: all var(--transition-fast);
    background: var(--bg-input);
}

.phone-input-wrapper:focus-within {
    border-color: var(--purple-500);
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.phone-prefix {
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-subtle);
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 42px;
    justify-content: center;
    transition: all var(--transition-base);
}

.phone-prefix.active {
    background: var(--purple-50);
    color: var(--purple-700);
    font-weight: 600;
    font-size: 0.82rem;
    min-width: auto;
    padding: 0 0.6rem;
}

.phone-input-wrapper input {
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* --- Select dropdown --- */
.form-group select {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--bg-input);
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all var(--transition-fast);
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    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='%239490A6' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    padding-right: 2.5rem;
}

.form-group select:focus {
    border-color: var(--purple-500);
    background-color: var(--bg-input-focus);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.form-group select option {
    padding: 0.5rem;
}

/* --- Autocomplete dropdown --- */
.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1.5px solid var(--purple-300);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 280px;
    overflow-y: auto;
    display: none;
}

.autocomplete-list.visible {
    display: block;
    animation: fadeIn 0.15s ease;
}

.autocomplete-item {
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: var(--purple-50);
}

.autocomplete-item .ac-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.autocomplete-item .ac-details {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.autocomplete-item .ac-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    background: var(--purple-100);
    color: var(--purple-700);
    margin-left: 0.4rem;
}

/* --- Upload section (admin) --- */
.upload-section {
    background: white;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-xs);
}

.upload-section h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.upload-zone {
    border: 2px dashed var(--border-default);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--bg-primary);
}

.upload-zone:hover {
    border-color: var(--purple-400);
    background: var(--purple-50);
}

.upload-zone.dragover {
    border-color: var(--purple-500);
    background: var(--purple-50);
}

.upload-zone .upload-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.upload-zone p { font-size: 0.85rem; color: var(--text-secondary); }
.upload-zone .upload-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.3rem; }

.upload-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
}

.upload-status.success { background: var(--teal-50); color: var(--teal-600); }
.upload-status.error { background: #FEF2F2; color: #DC2626; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    user-select: none;
}

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

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--purple-700), var(--purple-500));
    color: white;
    box-shadow: 0 4px 15px rgba(107, 33, 168, 0.25);
    padding: 0.85rem;
    font-size: 1rem;
    margin-top: 0.25rem;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 25px rgba(107, 33, 168, 0.35);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}

.btn-secondary:hover {
    background: var(--purple-50);
    color: var(--purple-700);
    border-color: var(--purple-200);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.btn-icon:hover {
    background: var(--purple-50);
    color: var(--purple-700);
    border-color: var(--purple-200);
}

.btn-danger {
    background: #FEF2F2;
    color: #DC2626;
    border: 1px solid #FECACA;
}

.btn-danger:hover {
    background: #FEE2E2;
}

/* Loading state */
.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Live Counter --- */
.live-counter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.85rem;
    background: var(--teal-50);
    border: 1px solid var(--teal-300);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--teal-600);
    margin-top: 1rem;
}

.live-counter .pulse {
    width: 7px;
    height: 7px;
    background: var(--teal-500);
    border-radius: 50%;
    animation: pulse 2s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.7); }
}

/* --- Success Toast --- */
.toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 0.85rem 1.25rem;
    background: #059669;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 500;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transform: translateX(120%);
    transition: transform var(--transition-slow);
    z-index: 1000;
    box-shadow: 0 8px 30px rgba(5, 150, 105, 0.3);
}

.toast.visible {
    transform: translateX(0);
}

.toast.error {
    background: #DC2626;
    box-shadow: 0 8px 30px rgba(220, 38, 38, 0.3);
}

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

.stat-card {
    background: white;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-xs);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.stat-card .stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.15rem;
}

.stat-card.purple .stat-value { color: var(--purple-600); }
.stat-card.teal .stat-value { color: var(--teal-600); }
.stat-card.orange .stat-value { color: #EA580C; }

/* --- Data Table --- */
.table-container {
    background: white;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.table-toolbar h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.table-toolbar .toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-input {
    padding: 0.45rem 0.85rem;
    padding-left: 2rem;
    background: var(--bg-input);
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    width: 260px;
    transition: all var(--transition-fast);
}

.search-input:focus {
    border-color: var(--purple-500);
    background: white;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.08);
}

.search-wrapper {
    position: relative;
}

.search-wrapper::before {
    content: '🔍';
    position: absolute;
    left: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
}

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

thead th {
    padding: 0.65rem 0.85rem;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-primary);
}

tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: var(--purple-50);
}

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

tbody td {
    padding: 0.65rem 0.85rem;
    font-size: 0.85rem;
    color: var(--text-primary);
}

td .td-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-status.printed {
    background: var(--teal-50);
    color: var(--teal-600);
}

.badge-status.pending {
    background: #FFF7ED;
    color: #EA580C;
}

.table-actions {
    display: flex;
    gap: 0.3rem;
}

.table-empty {
    text-align: center;
    padding: 2.5rem 2rem;
    color: var(--text-muted);
}

.table-empty .empty-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* --- Admin Layout --- */
.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

/* --- Footer --- */
.app-footer {
    text-align: center;
    padding: 0.75rem 2rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .main-content { padding: 1rem; }
    .card-body { padding: 1.25rem; }
    .form-row { grid-template-columns: 1fr; gap: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .admin-container { padding: 1rem; }
    .table-toolbar { flex-direction: column; align-items: stretch; }
    .search-input { width: 100%; }
    thead th, tbody td { padding: 0.5rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .app-header { flex-direction: column; gap: 0.5rem; padding: 0.75rem 1rem; }
}

/* --- Animations --- */
.fade-in {
    animation: fadeIn 0.35s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-up {
    animation: slideUp 0.4s var(--transition-slow) forwards;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Keyboard shortcut hint --- */
.shortcut-hint {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}

.shortcut-hint kbd {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-secondary);
}
