/* ============================================
   AMIGO SECRETO - Estilos principales
   ============================================ */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #f1f5f9;
    --accent: #10b981;
    --danger: #ef4444;
    --text: #1e293b;
    --text-light: #64748b;
    --text-lighter: #94a3b8;
    --bg: #ffffff;
    --bg-secondary: #f8fafc;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.app {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* ============================================
   SCREENS
   ============================================ */

.screen {
    display: none;
    width: 100%;
    max-width: 480px;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

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

.container {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
}

.container-wide {
    max-width: 600px;
}

#profile-screen .container {
    max-width: 600px;
}

#profile-screen {
    max-width: 640px;
}

/* ============================================
   LOGO & HEADER
   ============================================ */

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

.gift-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.gift-icon svg {
    width: 44px;
    height: 44px;
}

.logo h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.subtitle {
    color: var(--text-light);
    font-size: 15px;
    text-align: center;
    margin-bottom: 24px;
}

.btn-back {
    position: absolute;
    top: 16px;
    left: 16px;
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-back:hover {
    background: var(--secondary);
    color: var(--text);
}

.btn-back svg {
    width: 24px;
    height: 24px;
}

.container {
    position: relative;
}

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

.login-form, .profile-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.input-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    font-family: inherit;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    transition: var(--transition);
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input::placeholder, textarea::placeholder {
    color: var(--text-lighter);
}

input[readonly] {
    background: var(--secondary);
    cursor: not-allowed;
}

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

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn svg {
    width: 20px;
    height: 20px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-secondary {
    background: var(--secondary);
    color: var(--text);
}

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

.btn-small {
    padding: 10px 16px;
    font-size: 14px;
}

.btn-large {
    padding: 16px 32px;
    font-size: 17px;
    width: 100%;
}

.btn-ai {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.btn-ai svg {
    width: 16px;
    height: 16px;
}

.btn-ai:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

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

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

/* ============================================
   PHOTO UPLOAD
   ============================================ */

.photo-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.photo-preview {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 4px solid var(--border);
}

.photo-preview svg {
    width: 48px;
    height: 48px;
    color: var(--text-lighter);
}

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

.photo-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.photo-label svg {
    width: 18px;
    height: 18px;
}

.photo-label:hover {
    background: rgba(99, 102, 241, 0.15);
}

/* ============================================
   FORM SECTIONS
   ============================================ */

.form-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.form-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

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

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

.profile-header {
    text-align: center;
    margin-bottom: 24px;
}

.profile-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

/* ============================================
   CHECKBOX
   ============================================ */

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

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 15px;
    color: var(--text);
}

.checkbox-label input {
    display: none;
}

.checkmark {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.checkbox-label input:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-label input:checked + .checkmark::after {
    content: '';
    width: 6px;
    height: 10px;
    border: 2px solid white;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

/* ============================================
   GIFT LIST
   ============================================ */

#gift-list-container {
    transition: var(--transition);
}

#gift-list-container.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.gift-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0;
    max-height: 200px;
    overflow-y: auto;
}

.gift-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.gift-item span {
    font-size: 15px;
}

.gift-item button {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
}

.gift-item button:hover {
    background: rgba(239, 68, 68, 0.1);
}

.gift-item button svg {
    width: 18px;
    height: 18px;
}

.add-gift-row {
    display: flex;
    gap: 12px;
}

.add-gift-row input {
    flex: 1;
}

/* ============================================
   SUCCESS SCREEN
   ============================================ */

#success-screen .container {
    text-align: center;
}

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    background: linear-gradient(135deg, var(--accent) 0%, #059669 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.success-icon svg {
    width: 44px;
    height: 44px;
}

#success-screen h2 {
    font-size: 24px;
    margin-bottom: 12px;
}

#success-screen .subtitle {
    margin-bottom: 32px;
}

/* ============================================
   ERROR MESSAGE
   ============================================ */

.error-message {
    color: var(--danger);
    font-size: 14px;
    text-align: center;
    min-height: 20px;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg);
    padding: 40px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 1s linear infinite;
}

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

/* ============================================
   TOAST
   ============================================ */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: white;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    transition: transform 0.3s ease;
    z-index: 1001;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    background: var(--danger);
}

.toast.success {
    background: var(--accent);
}

/* ============================================
   FORM ACTIONS
   ============================================ */

.form-actions {
    margin-top: 24px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 480px) {
    .app {
        padding: 12px;
        align-items: flex-start;
    }

    .container {
        padding: 28px 20px;
    }

    .logo h1 {
        font-size: 24px;
    }

    .gift-icon {
        width: 64px;
        height: 64px;
        border-radius: 16px;
    }

    .gift-icon svg {
        width: 36px;
        height: 36px;
    }

    .form-section {
        padding: 16px;
    }

    .btn-large {
        padding: 14px 24px;
    }
}

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

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-header h2 {
    font-size: 24px;
    font-weight: 700;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius);
    text-align: center;
}

.stat-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 4px;
}

.participants-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.participant-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    transition: var(--transition);
}

.participant-card:hover {
    background: var(--border);
}

.participant-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.participant-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.participant-avatar svg {
    width: 28px;
    height: 28px;
    color: var(--text-lighter);
}

.participant-info {
    flex: 1;
    min-width: 0;
}

.participant-name {
    font-weight: 600;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.participant-email {
    font-size: 14px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.participant-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
    color: var(--text-light);
}

.btn-icon:hover {
    border-color: var(--primary);
}

.btn-icon:hover svg {
    color: var(--primary);
}

.btn-icon.danger:hover {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.btn-icon.danger:hover svg {
    color: var(--danger);
}

.admin-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.admin-actions .btn {
    flex: 1;
    min-width: 200px;
}

.sorteo-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 16px;
}

.sorteo-status svg {
    width: 20px;
    height: 20px;
}

.sorteo-status.pending {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

#admin-screen {
    max-width: 800px;
}

#admin-screen .container {
    max-width: 100%;
}

.config-section {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.config-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.config-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

    .admin-actions .btn {
        min-width: 100%;
    }
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-light);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Modal de detalle participante */
.participant-detail {
    max-width: 500px;
    width: 100%;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.detail-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--secondary);
}

.detail-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detail-info h3 {
    font-size: 20px;
    margin-bottom: 4px;
}

.detail-info p {
    color: var(--text-light);
}

.detail-section {
    margin-bottom: 16px;
}

.detail-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.detail-section-content {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
}

/* ============================================
   MODO OSCURO
   ============================================ */

[data-theme="dark"] {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --primary-light: #a5b4fc;
    --secondary: #1e293b;
    --accent: #34d399;
    --danger: #f87171;
    --text: #f1f5f9;
    --text-light: #94a3b8;
    --text-lighter: #64748b;
    --bg: #0f172a;
    --bg-secondary: #1e293b;
    --border: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

[data-theme="dark"] .gift-icon {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #4338ca 100%);
}

[data-theme="dark"] .btn-primary {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #4338ca 100%);
}

[data-theme="dark"] .modal {
    background: rgba(0, 0, 0, 0.7);
}

/* ============================================
   TOGGLE DE TEMA
   ============================================ */

.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg);
    border: 2px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 100;
    box-shadow: var(--shadow);
}

.theme-toggle:hover {
    transform: scale(1.1);
    border-color: var(--primary);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    color: var(--text);
    transition: var(--transition);
}

.theme-toggle .icon-moon {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: block;
}

/* ============================================
   ANIMACIONES MEJORADAS
   ============================================ */

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

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

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

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

.screen.active {
    animation: slideUp 0.4s ease;
}

.form-section {
    animation: slideIn 0.3s ease;
    animation-fill-mode: both;
}

.form-section:nth-child(1) { animation-delay: 0.1s; }
.form-section:nth-child(2) { animation-delay: 0.2s; }
.form-section:nth-child(3) { animation-delay: 0.3s; }
.form-section:nth-child(4) { animation-delay: 0.4s; }

.modal.active .modal-content {
    animation: scaleIn 0.3s ease;
}

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

.gift-item {
    animation: slideIn 0.2s ease;
}

.photo-preview {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.photo-preview:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.3);
}

input:focus, textarea:focus {
    transform: translateY(-1px);
}

/* ============================================
   PREVIEW DEL PERFIL
   ============================================ */

.preview-content {
    max-width: 450px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    text-align: left;
    padding: 0;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 1;
}

.preview-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.btn-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--secondary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-close svg {
    width: 20px;
    height: 20px;
    color: var(--text-light);
}

.btn-close:hover {
    background: var(--danger);
}

.btn-close:hover svg {
    color: white;
}

.preview-body {
    padding: 24px;
}

.preview-card {
    text-align: center;
}

.preview-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 0 auto 16px;
    overflow: hidden;
    background: var(--secondary);
    border: 4px solid var(--primary);
}

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

.preview-name {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.preview-nickname {
    color: var(--text-light);
    font-size: 16px;
    margin-bottom: 20px;
}

.preview-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
    text-align: left;
}

.preview-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.preview-section-content {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
}

.preview-gifts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.preview-gift-tag {
    background: var(--primary);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

/* ============================================
   FORM ACTIONS MEJORADO
   ============================================ */

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-actions .btn {
    flex: 1;
}

@media (max-width: 500px) {
    .form-actions {
        flex-direction: column;
    }

    .theme-toggle {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
    }

    .theme-toggle svg {
        width: 20px;
        height: 20px;
    }
}
