/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    overflow: hidden;
}

:root {
    --primary-gradient: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 50%, #ff9ff3 100%);
    --secondary-gradient: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
    --success-gradient: linear-gradient(135deg, #00b894 0%, #00a085 100%);
    --danger-gradient: linear-gradient(135deg, #e17055 0%, #d63031 100%);
    --warning-gradient: linear-gradient(135deg, #fdcb6e 0%, #e17055 100%);
    --dark-gradient: linear-gradient(135deg, #2d3436 0%, #636e72 100%);
    --glass-bg: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.18);
    --text-primary: #2d3436;
    --text-secondary: #636e72;
    --text-light: #ddd;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--primary-gradient);
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
}

/* Screens */
.screen {
    display: none;
    flex: 1;
    overflow: hidden;
    animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Form */
.form {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
    font-weight: 500;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #ff6b6b;
    background: white;
    box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.2);
    transform: translateY(-2px);
}

.form-button-container {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

/* Buttons */
.btn {
    border: none;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    min-height: 52px;
    padding: 14px 28px;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: var(--secondary-gradient);
    color: white;
    box-shadow: 0 8px 25px rgba(116, 185, 255, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 35px rgba(116, 185, 255, 0.6);
}

.btn-secondary {
    background: var(--dark-gradient);
    color: white;
    box-shadow: 0 8px 25px rgba(45, 52, 54, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 35px rgba(45, 52, 54, 0.6);
}

.btn-success {
    background: var(--success-gradient);
    color: white;
    box-shadow: 0 8px 25px rgba(0, 184, 148, 0.4);
}

.btn-danger {
    background: var(--danger-gradient);
    color: white;
    box-shadow: 0 8px 25px rgba(214, 48, 49, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.btn-danger:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 35px rgba(214, 48, 49, 0.6);
}

.btn-large {
    flex: 2;
    font-size: 1.3rem;
    padding: 18px 32px;
    margin: 0 8px;
    min-height: 60px;
}

.btn-icon {
    flex: 1;
    min-width: 60px;
    min-height: 60px;
    padding: 0;
    font-size: 1.4rem;
    border-radius: 20px;
}

.btn-icon i {
    display: flex;
    align-items: center;
    justify-content: center;
    color: currentColor;
}

.btn i {
    display: inline-flex;
    align-items: center;
    color: currentColor;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Voting screen */
.voting-header {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 24px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
}

.voting-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.circuito-mesa {
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.2rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.current-orden {
    font-size: 1.4rem;
    font-weight: 800;
    color: #ff6b6b;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.progress-fill {
    height: 100%;
    background: var(--secondary-gradient);
    border-radius: 10px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
    box-shadow: 0 2px 8px rgba(116, 185, 255, 0.4);
}

/* Voting card */
.voting-card-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
}

.voting-card {
    width: 300px;
    height: 420px;
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: 32px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: grab;
    user-select: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: pan-y;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.voting-card:active {
    cursor: grabbing;
}

.voting-card.swiping-left {
    transform: translateX(-60px) rotate(-8deg) scale(1.05);
    background: var(--danger-gradient);
    border: 3px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 30px 60px rgba(214, 48, 49, 0.4);
}

.voting-card.swiping-right {
    transform: translateX(60px) rotate(8deg) scale(1.05);
    background: var(--success-gradient);
    border: 3px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 30px 60px rgba(0, 184, 148, 0.4);
}

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

.orden-number {
    font-size: 7rem;
    font-weight: 900;
    color: var(--text-primary);
    margin-bottom: 24px;
    text-shadow: 0 4px 8px rgba(0,0,0,0.2);
    background: var(--secondary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.swipe-instructions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 220px;
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.swipe-left, .swipe-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.swipe-left {
    color: #e17055;
}

.swipe-right {
    color: #00b894;
}

.icon {
    font-size: 1.8rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Voting controls */
.voting-controls {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    align-items: center;
    justify-content: center;
}

/* Confirmation screen */
.votes-summary {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.summary-stats {
    display: flex;
    justify-content: space-around;
}

.stat {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 3rem;
    font-weight: 900;
    background: var(--secondary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stat-label {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.votes-table-container {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    max-height: 350px;
    overflow-y: auto;
}

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

.votes-table th,
.votes-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.votes-table th {
    background: rgba(255, 255, 255, 0.2);
    font-weight: 700;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
}

.votes-table td {
    color: var(--text-primary);
    font-weight: 500;
}

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

.confirmation-controls {
    display: flex;
    gap: 12px;
}

.confirmation-controls .btn {
    flex: 1;
}

/* Success screen */
.success-content {
    text-align: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 48px 36px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.success-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.success-content h2 {
    font-size: 2.5rem;
    color: var(--text-primary);
    margin-bottom: 16px;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.success-content p {
    color: var(--text-secondary);
    margin-bottom: 28px;
    font-size: 1.2rem;
    font-weight: 500;
}

.success-stats {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 28px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.success-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 1000;
    color: white;
}

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

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    max-width: 300px;
}

.toast {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    border-left: 4px solid #10b981;
    animation: slideIn 0.3s ease-out;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.warning {
    border-left-color: #f59e0b;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive design */
@media (max-width: 480px) {
    .container {
        padding: 8px 8px 20px 8px; /* Más padding bottom para botones */
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .form {
        padding: 24px;
    }
    
    .voting-card {
        width: 260px;
        height: 380px;
    }
    
    .orden-number {
        font-size: 5rem;
    }
    
    .voting-controls {
        flex-direction: row;
        gap: 8px;
    }
    
    .btn-half,
    .btn-quarter {
        flex: 1;
        margin: 0;
    }
    
    .confirmation-controls {
        flex-direction: column;
    }
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 52px;
        font-size: 1.1rem;
    }
    
    .voting-card {
        width: 300px;
        height: 420px;
    }
    
    .orden-number {
        font-size: 6.5rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .form,
    .voting-header,
    .votes-summary,
    .votes-table-container,
    .success-content {
        background: #1f2937;
        color: #f9fafb;
    }
    
    .form-group input,
    .form-group select {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .form-group input:focus,
    .form-group select:focus {
        background: #4b5563;
        border-color: #2563eb;
    }
    
    .votes-table th {
        background: #374151;
        color: #f9fafb;
    }
    
    .votes-table td {
        color: #d1d5db;
    }
    
    .votes-table th,
    .votes-table td {
        border-bottom-color: #4b5563;
    }
}

/* Login page styles */
#login-app {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 40px 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.app-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.logo-icon {
    font-size: 48px;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.login-header h1 {
    font-size: 28px;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.login-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 8px 0 4px 0;
    font-weight: 500;
}

.login-description {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

.login-form {
    margin-bottom: 30px;
}

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

.login-form label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 14px;
}

.login-form input {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-primary);
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.login-form input[type="password"] {
    color: var(--text-primary);
    font-weight: 500;
    letter-spacing: 2px;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.1);
}

.login-btn {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.login-footer {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.security-note {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
    min-width: 300px;
    max-width: 400px;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-success {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: #059669;
}

.toast-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

.toast-info {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: #2563eb;
}

/* Banner de modo prueba */
.test-mode-banner {
    background: linear-gradient(135deg, #ff6b6b, #ff9ff3);
    color: white;
    text-align: center;
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.3);
    animation: pulse 2s infinite;
}

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

/* Toast de confirmación personalizado */
.confirm-toast {
    max-width: 350px;
    padding: 20px;
}

.confirm-message {
    margin-bottom: 16px;
    font-weight: 500;
    text-align: center;
}

.confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-confirm-yes,
.btn-confirm-no {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-confirm-yes {
    background: #dc2626;
    color: white;
}

.btn-confirm-yes:hover {
    background: #b91c1c;
    transform: translateY(-1px);
}

.btn-confirm-no {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-confirm-no:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}
