/**
 * Modern Professional Client Interface
 * School Voting Application
 */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #1f2937;
    background: #f8fafc;
    overflow-x: hidden;
}

/* Main Container */
.voting-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

#votingScreen.active~.voting-header,
.voting-container:has(#votingScreen.active) .voting-header {
    display: none;
}

/* Header */
.voting-header {
    text-align: center;
    padding: 2rem 1.5rem;
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

#votingScreen .voting-header {
    display: none;
}

.voting-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

.subtitle {
    font-size: 1.125rem;
    opacity: 0.9;
    font-weight: 400;
}

/* Screen Management */
.screen {
    display: none;
    flex: 1;
    padding: 2rem;
    animation: fadeOut 0.2s ease-out;
}

.screen.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease-in;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Card Styles */
.login-card,
.menu-card,
.session-card,
.success-card {
    background: white;
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid #e5e7eb;
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.login-card h2,
.menu-card h2,
.session-card h2,
.success-card h2 {
    font-size: 1.875rem;
    margin-bottom: 1rem;
    color: #111827;
    font-weight: 600;
}

.login-card p,
.menu-card p,
.session-card p {
    color: #6b7280;
    margin-bottom: 2rem;
    font-size: 1rem;
}

/* Form Styles */
.login-form,
.session-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.login-form input,
.session-form input {
    padding: 0.875rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: #f9fafb;
}

.login-form input:focus,
.session-form input:focus {
    outline: none;
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    min-height: 48px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: #3b82f6;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    background: #2563eb;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #6b7280;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    background: #4b5563;
    transform: translateY(-1px);
}

.btn-success {
    background: #10b981;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: #3b82f6;
    border: 2px solid #3b82f6;
    box-shadow: none;
}

.btn-outline:hover {
    background: #3b82f6;
    color: white;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
    min-height: 56px;
}

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

/* Menu Options */
.menu-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.menu-btn {
    padding: 1.5rem;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: white;
    border: 2px solid #e5e7eb;
    color: #374151;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.menu-btn:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.btn-icon {
    font-size: 1.5rem;
    opacity: 0.8;
}

.btn-text {
    flex: 1;
}

.btn-text strong {
    display: block;
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
    color: #111827;
}

.btn-text small {
    color: #6b7280;
    font-size: 0.875rem;
}

/* Voting Screen Styles */
#votingScreen.screen.active {
    padding: 0;
    justify-content: flex-start;
    align-items: stretch;
}

.display-controls {
    background: white;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.controls-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: #6b7280;
}

.controls-group label {
    font-weight: 500;
    white-space: nowrap;
}

.control-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    user-select: none;
}

.control-btn:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.voting-content {
    flex: 1;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.voting-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.session-info,
.progress-info {
    font-size: 1rem;
    color: #6b7280;
}

.session-info strong,
.progress-info span {
    color: #111827;
    font-weight: 600;
}

.position-title {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    position: relative;
}

.position-title h2 {
    font-size: 1.75rem;
    color: #111827;
    font-weight: 700;
    margin: 0;
}



.settings-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    color: #6b7280;
}

.settings-button:hover {
    background: #f3f4f6;
    color: #374151;
}

/* Settings Modal */
.settings-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);
}

.settings-modal.active {
    display: flex;
}

.settings-modal-content {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.settings-modal h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #111827;
    text-align: center;
}

.settings-group {
    margin-bottom: 1.5rem;
}

.settings-group label {
    display: block;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.settings-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.settings-controls button {
    width: 40px;
    height: 40px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.settings-controls button:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.settings-value {
    font-weight: 600;
    color: #111827;
    min-width: 80px;
    text-align: center;
}

.settings-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.settings-actions button {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-reset {
    background: #f3f4f6;
    color: #374151;
}

.btn-reset:hover {
    background: #e5e7eb;
}

.btn-close {
    background: #3b82f6;
    color: white;
}

.btn-close:hover {
    background: #2563eb;
}

/* NEW: Capsule/Tab Style Candidates */
.candidates-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* Default 3 columns */
    gap: 1rem;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
}

/* Grid column variations */
.candidates-container.cols-1 {
    grid-template-columns: 1fr;
}

.candidates-container.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.candidates-container.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.candidates-container.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.candidates-container.cols-5 {
    grid-template-columns: repeat(5, 1fr);
}

.candidates-container.cols-6 {
    grid-template-columns: repeat(6, 1fr);
}

.candidate-card {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    min-height: 140px;
}

.candidate-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.candidate-card.selected {
    border-color: #10b981;
    background: #f0fdf4;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.2);
}

.candidate-images {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.candidate-profile img {
    width: 148px;
    height: 148px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e5e7eb;
    transition: all 0.2s ease;
}

.candidate-emblem img {
    width: 132px;
    height: 132px;
    object-fit: contain;
    border-radius: 6px;
}

.candidate-card.selected .candidate-profile img {
    border-color: #10b981;
}

.candidate-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.candidate-info h3 {
    font-size: 1rem;
    color: #111827;
    margin-bottom: 0.25rem;
    font-weight: 600;
    line-height: 1.3;
}

.candidate-info p {
    color: #6b7280;
    font-size: 0.8rem;
    line-height: 1.3;
}

.selection-indicator {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #10b981;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0);
    transition: all 0.2s ease;
}

.candidate-card.selected .selection-indicator {
    opacity: 1;
    transform: scale(1);
}

.checkmark {
    color: white;
    font-weight: bold;
    font-size: 14px;
}

/* Voting Actions */
.voting-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

/* Success Screen */
.success-card {
    max-width: 600px;
}

.success-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.session-reminder {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 12px;
    margin: 1.5rem 0;
    border-left: 4px solid #3b82f6;
}

.session-id-display {
    font-size: 1.5rem;
    font-weight: bold;
    color: #3b82f6;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    margin: 0.75rem 0;
    border: 2px solid #e5e7eb;
    letter-spacing: 2px;
}

/* Error Messages */
.error-message {
    background: #fef2f2;
    color: #b91c1c;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    display: none;
    border: 1px solid #fecaca;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

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

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

    100% {
        transform: rotate(360deg);
    }
}

.loading-overlay p {
    color: white;
    font-size: 1rem;
    font-weight: 500;
}

/* Voting Disabled */
.disabled-message {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex: 1;
    text-align: center;
    padding: 3rem;
}

.disabled-icon {
    font-size: 4rem;
    margin-bottom: 2rem;
    opacity: 0.7;
}

.disabled-message h2 {
    font-size: 2rem;
    color: #1f2937;
    margin-bottom: 1rem;
    font-weight: 600;
}

.disabled-message p {
    color: #6b7280;
    font-size: 1.125rem;
    margin-bottom: 1rem;
    max-width: 600px;
}

.admin-link {
    margin-top: 2rem;
}

@media (max-width: 480px) {
    .candidates-container {
        grid-template-columns: 1fr !important;
    }
}

/* Responsive Design */
@media (max-width: 768px) {

    .candidates-container.cols-4,
    .candidates-container.cols-5,
    .candidates-container.cols-6 {
        grid-template-columns: repeat(2, 1fr);
    }

    .voting-header {
        padding: 1.5rem 1rem;
    }

    .voting-header h1 {
        font-size: 2rem;
    }

    .screen {
        padding: 1rem;
    }

    .login-card,
    .menu-card,
    .session-card,
    .success-card {
        padding: 2rem;
        margin: 0.5rem;
    }

    .candidate-card {
        padding: 1rem;
    }

    .candidate-profile img {
        width: 40px;
        height: 40px;
    }

    .candidate-emblem img {
        width: 28px;
        height: 28px;
    }

    .voting-header-info {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .voting-actions {
        flex-direction: column;
    }

    .display-controls {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .controls-group {
        justify-content: center;
    }
}

/* Site-wide Footer */
.app-footer {
    margin-top: auto;
    padding: 1rem 0;
    background: transparent;
    border-top: 1px solid #e5e7eb;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    text-align: center;
}

.footer-text {
    margin: 0;
    font-size: 0.875rem;
    color: #9ca3af;
}

.footer-text a {
    color: #6b7280;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-text a:hover {
    color: #374151;
}

/* School Header Styles */
.school-header {
    width: 100%;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.welcome-bar {
    background: linear-gradient(135deg, #b45309 0%, #d97706 100%);
    color: white;
    padding: 0.75rem 0;
}

.welcome-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    text-align: center;
}

.welcome-text {
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.025em;
}

.main-header {
    background: white;
    padding: 1.5rem 0;
    border-bottom: 3px solid #d97706;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.school-logo {
    flex-shrink: 0;
}

.logo-image {
    width: 100px;
    height: 100px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.school-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.school-title {
    text-align: center;
}

.school-name-line1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e40af;
    margin: 0;
    letter-spacing: 0.025em;
    line-height: 1.2;
}

.school-name-line2 {
    font-size: 2rem;
    font-weight: 700;
    color: #d97706;
    margin: 0.25rem 0 0.5rem 0;
    letter-spacing: 0.025em;
    line-height: 1.1;
}

.system-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #374151;
    margin: 0;
    padding: 0.5rem 1rem;
    background: #f3f4f6;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
}

.school-details {
    text-align: center;
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.5;
}

.school-details p {
    margin: 0.25rem 0;
}

.affiliation {
    font-weight: 500;
    color: #374151;
}

.contact {
    font-weight: 400;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }

    .logo-image {
        width: 80px;
        height: 80px;
    }

    .school-name-line1 {
        font-size: 1rem;
    }

    .school-name-line2 {
        font-size: 1.5rem;
    }

    .system-title {
        font-size: 1rem;
    }

    .welcome-text {
        font-size: 0.85rem;
    }

    .school-details {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .main-header {
        padding: 1rem 0;
    }

    .welcome-bar {
        padding: 0.5rem 0;
    }

    .logo-image {
        width: 70px;
        height: 70px;
    }

    .school-name-line2 {
        font-size: 1.25rem;
    }

    .system-title {
        font-size: 0.9rem;
        padding: 0.375rem 0.75rem;
    }
}

/* Hide school header in voting screen to save space */
#votingScreen.screen.active~.school-header,
#votingScreen.screen.active+.school-header,
body:has(#votingScreen.active) .school-header {
    display: none;
}

/* Alternative approach - more reliable */
.voting-screen-active .school-header {
    display: none;
}

/* Hide header when voting screen is active */
.screen.active#votingScreen~* .school-header,
.voting-active .school-header {
    display: none;
}