:root {
    --primary: #1e40af; /* Deep Royal Blue */
    --primary-dark: #1e3a8a;
    --primary-light: #dbeafe;
    --accent: #f59e0b; /* Gold/Amber */
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text-main: #1e293b;
    --text-secondary: #64748b;
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    margin: 0;
    color: var(--text-main);
    line-height: 1.5;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    border: 1px solid #fecaca;
}

.election-closed-container {
    text-align: center;
    padding: 60px 0;
}

.election-closed-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.election-closed-title {
    color: #475569;
}

.election-closed-message {
    color: #64748b;
}

.position-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.position-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.empty-state-message {
    padding: 40px;
    text-align: center;
    color: #64748b;
}

.candidate-photo-placeholder {
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    width: 100%;
    height: 100%;
    border-radius: 12px;
}

.modal-profile-photo-container {
    text-align: center;
    margin-bottom: 20px;
}

.modal-profile-photo {
    width: 150px;
    height: 150px;
    border-radius: 12px;
    object-fit: cover;
    border: 4px solid #f1f5f9;
}

.modal-profile-bio {
    background: #f8fafc;
    padding: 20px;
    border-radius: 12px;
    line-height: 1.6;
    color: #334155;
}

.input-code {
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.warning-text {
    color: #ef4444;
    font-size: 14px;
    margin-top: 10px;
    font-weight: 600;
}

/* Auth Pages (Login / Get Code) */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background-color: var(--bg-body);
    /* Gradient overlay + Background Image */
    background-image: 
        linear-gradient(135deg, rgba(241, 245, 249, 0.85) 0%, rgba(224, 242, 254, 0.85) 100%),
        url('../img/login-bg.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

.auth-container {
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.4);
    max-width: 440px;
    width: 100%;
    border-top: none;
    position: relative;
    overflow: hidden;
}

.auth-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.auth-title {
    margin-top: 10px;
    font-size: 28px;
    text-align: center;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 15px;
    line-height: 1.5;
}

.auth-error {
    background-color: #fee2e2;
    color: red;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #fecaca;
    animation: slideDown 0.3s ease-out;
}

.auth-error::before {
    content: '⚠️';
    font-size: 16px;
}

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

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

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

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    font-size: 18px;
    color: var(--text-secondary);
    z-index: 10;
    pointer-events: none;
}

.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 10;
    transition: color 0.2s;
    background: none;
    border: none;
    padding: 0;
}

.password-toggle:hover {
    color: var(--primary);
}

.auth-input {
    width: 100%;
    padding: 14px 44px 14px 44px; /* Space for icon and toggle */
    border-radius: 12px;
    border: 2px solid transparent;
    background-color: #f8fafc;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.2s ease;
    color: var(--text-main);
}

.auth-input:focus {
    outline: none;
    background-color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.auth-input::placeholder {
    color: #94a3b8;
}

.input-code {
    text-align: center;
    letter-spacing: 3px;
    font-weight: 700;
    font-family: monospace;
    padding-left: 14px; /* Override for centered text if no icon, but here we have icon */
    padding-left: 44px; /* Keep icon space */
}

.auth-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    color: #ffffff;
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 20px -10px var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.auth-btn:hover {
    filter: brightness(110%);
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -12px var(--primary-dark);
}

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

.btn-icon {
    transition: transform 0.2s;
}

.auth-btn:hover .btn-icon {
    transform: translateX(4px);
}

.auth-tabs {
    display: flex;
    margin-bottom: 32px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 14px;
    position: relative;
    border: none;
}

.auth-tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
}

.auth-tab:hover {
    color: var(--text-main);
}

.auth-tab.active {
    background-color: #fff;
    color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: none;
    margin-bottom: 0;
}

.tab-icon {
    font-size: 16px;
}


.auth-link {
    display: block;
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* Get Code Specific */
.code-display {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 2px;
    margin: 20px 0;
    padding: 16px;
    background-color: var(--bg-body);
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
}

/* Voting App Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #fff;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.brand {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sidebar-nav {
    padding: 20px 12px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-item.active {
    background: #fff;
    color: var(--primary-dark);
    box-shadow: var(--shadow-md);
    font-weight: 600;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.2);
}

.user-mini {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #fff;
    border: 2px solid rgba(255,255,255,0.2);
}

.user-info div:first-child { font-weight: 600; font-size: 14px; }
.user-info div:last-child { font-size: 12px; color: #94a3b8; }

/* Main Content */
.main {
    margin-left: 260px;
    flex: 1;
    padding: 0;
    min-height: 100vh;
}

.top-header {
    background: #fff;
    padding: 20px 40px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: var(--shadow-sm);
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
}

.logout-btn {
    color: var(--danger);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 6px;
    background: #fef2f2;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: #fee2e2;
}

.content-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px 100px;
}

/* Hero / Notices */
.hero-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-lg);
    padding: 30px;
    color: #fff;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255,255,255,0.1);
}

.hero-title {
    font-size: 28px;
    font-weight: 800;
    margin: 0 0 10px;
}

.hero-subtitle {
    opacity: 0.9;
    font-size: 16px;
    max-width: 600px;
}

.notices-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.notice-card {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 20px;
    border-left: 4px solid var(--accent);
    box-shadow: var(--shadow-sm);
}

.notice-card h3 { margin: 0 0 8px; color: var(--text-main); font-size: 16px; }
.notice-card p { margin: 0; font-size: 14px; color: var(--text-secondary); white-space: pre-wrap; }

/* Progress Bar */
.progress-container {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 30px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.progress-text { font-weight: 600; color: var(--text-main); }
.progress-bar-wrapper {
    flex: 1;
    height: 10px;
    background: #e2e8f0;
    border-radius: 99px;
    margin: 0 20px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--success), #34d399);
    /* width is set inline */
    transition: width 0.5s ease;
}

/* Voting Section */
.position-section {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 40px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-top: 4px solid var(--primary); /* Added color accent */
}

.position-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to right, #f8fafc, #f1f5f9);
}

.position-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
}

.position-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.status-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-pending { background: #fef3c7; color: #d97706; }
.badge-completed { background: #dcfce7; color: #166534; }

.candidates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 24px;
}

.candidate-card {
    position: relative;
    cursor: pointer;
}

.candidate-card input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.card-inner {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    transition: all 0.2s ease;
    height: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.candidate-card:hover .card-inner {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: #cbd5e1;
}

.candidate-card input[type="radio"]:checked + .card-inner {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
    background: #fff; /* Keep white bg */
}

.photo-wrapper {
    width: 100px;
    height: 100px;
    margin-bottom: 16px;
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    background: #f1f5f9;
    box-shadow: var(--shadow-sm);
}

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

.candidate-photo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    background: #e2e8f0;
    color: #94a3b8;
}

.candidate-name {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 6px;
    color: var(--text-main);
    line-height: 1.2;
}

.candidate-position-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 20px;
    flex-grow: 1;
}

.vote-btn-container {
    width: 100%;
    margin-top: auto;
}

.btn-vote {
    background: var(--primary);
    color: #fff;
    border-radius: 12px;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s;
    width: 100%;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0; /* Hide direct text */
}

.btn-vote::after {
    content: "Vote";
    font-size: 16px;
}

.candidate-card:hover .btn-vote {
    background: var(--primary-dark);
}

.candidate-card input[type="radio"]:checked + .card-inner .btn-vote {
    background: var(--success);
}

.candidate-card input[type="radio"]:checked + .card-inner .btn-vote::after {
    content: "Selected";
}

.btn-view-profile-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    text-decoration: underline;
    margin-top: 12px;
    cursor: pointer;
    padding: 4px;
}

.btn-view-profile-link:hover {
    color: var(--primary);
}

/* Floating Submit Bar */
.submit-bar {
    position: fixed;
    bottom: 0;
    left: 260px;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    padding: 20px 40px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 40;
    border-top: 1px solid var(--border);
}

.submit-info {
    font-size: 14px;
    color: var(--text-secondary);
}

.btn-submit {
    background: linear-gradient(to right, var(--success), #059669);
    color: #fff;
    border: none;
    padding: 14px 32px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
    transition: all 0.2s;
}

.btn-submit:hover {
    filter: brightness(110%);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.4);
}

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

.modal-card {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: slideUp 0.3s ease-out;
}

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

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title { font-size: 20px; font-weight: 700; margin: 0; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #94a3b8; }

.modal-content { padding: 20px; overflow-y: auto; }

.review-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}
.review-pos { font-weight: 600; color: #475569; }
.review-sel { font-weight: 500; color: var(--text-main); }
.review-sel.empty { color: var(--danger); font-style: italic; }

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #f8fafc;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.btn-cancel {
    background: #fff;
    border: 1px solid var(--border);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
}

.alert-box {
    background: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Position Navigation and Search */
.position-nav {
    position: sticky;
    top: 73px; /* Height of top-header */
    background: #fff;
    z-index: 30;
    padding: 10px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 10px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}
.position-nav::-webkit-scrollbar { display: none; }

.nav-pill {
    padding: 8px 16px;
    background: #f1f5f9;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid transparent;
}
.nav-pill:hover { background: #e2e8f0; color: #334155; }
.nav-pill.active { background: var(--primary-light); color: var(--primary); border-color: rgba(37,99,235,0.2); }

.search-container {
    margin-left: auto;
    position: relative;
}
.search-input {
    padding: 8px 12px 8px 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    width: 200px;
    transition: width 0.2s;
}
.search-input:focus { width: 250px; outline: none; border-color: var(--primary); }
.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 14px;
}

.toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #64748b;
    transition: transform 0.3s;
}
.toggle-btn.rotated { transform: rotate(180deg); }

.position-body {
    max-height: 5000px;
    transition: max-height 0.5s ease-in-out;
    overflow: hidden;
}
.position-body.collapsed { max-height: 0; }

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    .sidebar-nav, .sidebar-footer { display: none; }
    .main { margin-left: 0; }
    .top-header { padding: 16px 20px; }
    .content-container { padding: 20px; }
    .submit-bar { left: 0; padding: 16px 20px; flex-direction: column; gap: 12px; text-align: center; }
    .btn-submit { width: 100%; }
    .notices-grid { grid-template-columns: 1fr; }
    
    .position-nav { top: 60px; padding: 10px 20px; margin: 0 -20px 20px; }
    .search-input { width: 140px; }
    .search-input:focus { width: 180px; }
}
