/* style.css - Complete Student Union Election System Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --error-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #3498db;
    --light-bg: #ecf0f1;
    --dark-text: #2c3e50;
    --border-radius: 8px;
    --box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-text);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.header {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: var(--box-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.header h1 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin: 0;
}

.user-info {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Button Styles */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    text-decoration: none;
    font-size: 16px;
    transition: var(--transition);
    font-weight: 500;
}

.btn-primary {
    background: var(--secondary-color);
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: var(--light-bg);
    color: var(--dark-text);
}

.btn-secondary:hover {
    background: #bdc3c7;
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #229954;
    transform: translateY(-2px);
}

.btn-small {
    padding: 5px 10px;
    font-size: 14px;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Form Styles */
.form-container {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    max-width: 500px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--primary-color);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 16px;
    transition: var(--transition);
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group input.error {
    border-color: var(--error-color);
}

.form-group input.error:focus {
    border-color: var(--error-color);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.form-text {
    display: block;
    margin-top: 5px;
    font-size: 0.85rem;
    color: #666;
}

/* Alert Styles */
.alert {
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    animation: slideIn 0.3s ease;
    color: white;
    font-weight: 500;
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.alert-success {
    background: var(--success-color);
}

.alert-error {
    background: var(--error-color);
}

.alert-info {
    background: var(--info-color);
}

.alert-warning {
    background: var(--warning-color);
}

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: var(--box-shadow);
}

.hero-section h2 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.hero-section p {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 30px;
}

.cta-buttons {
    margin-top: 30px;
    display: flex;
    gap: 20px;
    justify-content: center;
}

/* Info Section */
.info-section {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.info-section h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.info-section ul {
    list-style: none;
    padding: 0;
}

.info-section li {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
}

.info-section li:last-child {
    border-bottom: none;
}

.info-section li:before {
    content: "✓";
    color: var(--success-color);
    margin-right: 15px;
    font-weight: bold;
    font-size: 1.2rem;
}

/* Candidates Grid */
.candidates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.candidate-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.candidate-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.candidate-photo {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 20px;
    border: 4px solid var(--secondary-color);
    transition: var(--transition);
}

.candidate-card:hover .candidate-photo {
    transform: scale(1.05);
    border-color: var(--primary-color);
}

.candidate-photo.placeholder {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 48px;
    font-weight: bold;
}

.candidate-card h3 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.4rem;
}

.candidate-background {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
    flex-grow: 1;
    line-height: 1.5;
}

.vote-form {
    margin-top: auto;
}

/* Admin Section */
.admin-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--box-shadow);
}

.admin-section h2 {
    color: var(--primary-color);
    margin-bottom: 25px;
    border-bottom: 2px solid #eee;
    padding-bottom: 15px;
    font-size: 1.8rem;
}

.admin-section h3 {
    color: var(--primary-color);
    margin: 20px 0 15px;
    font-size: 1.4rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.stat-card h3 {
    color: white;
    font-size: 1.1rem;
    margin-bottom: 10px;
    opacity: 0.9;
    border-bottom: none;
    padding-bottom: 0;
}

.stat-number {
    font-size: 2.8rem;
    font-weight: bold;
    line-height: 1.2;
}

/* Vote Bars */
.vote-bars {
    margin: 30px 0;
    padding: 25px;
    background: var(--light-bg);
    border-radius: var(--border-radius);
}

.vote-bar-item {
    margin-bottom: 20px;
}

.candidate-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 500;
}

.progress-bar {
    height: 35px;
    background: #e0e0e0;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color), #667eea);
    transition: width 1s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 15px;
    color: white;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Report Actions */
.report-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 25px;
    flex-wrap: wrap;
}

.report-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 25px;
}

.icon-pdf:before {
    content: "📄";
    font-size: 1.2rem;
}

.icon-csv:before {
    content: "📊";
    font-size: 1.2rem;
}

/* Stats Table */
.stats-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.stats-table thead {
    background: var(--primary-color);
    color: white;
}

.stats-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 1rem;
}

.stats-table td {
    padding: 15px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.stats-table tbody tr:hover {
    background: var(--light-bg);
}

.stats-table tbody tr:last-child td {
    border-bottom: none;
}

.vote-count {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--secondary-color);
}

/* Back Link */
.back-link {
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--primary-color);
    transform: translateX(-5px);
}

/* Text Utilities */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* Loading Spinner */
.spinner {
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid var(--secondary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

.spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 5px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Search Input */
.search-input {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 25px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 16px;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Table Responsive */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 20px 0;
}

/* Chart Modal */
.chart-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.chart-container {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.chart-container h3 {
    color: var(--primary-color);
    margin-bottom: 25px;
    font-size: 1.5rem;
    text-align: center;
    border-bottom: 2px solid #eee;
    padding-bottom: 15px;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.close-btn:hover {
    background: #f0f0f0;
    color: var(--error-color);
    transform: rotate(90deg);
}

.chart-wrapper {
    width: 100%;
    height: auto;
    min-height: 400px;
}

/* Image Preview */
.image-preview {
    text-align: center;
    margin-top: 15px;
}

.image-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 3px solid var(--secondary-color);
}

/* Character Counter */
.char-counter {
    display: block;
    margin-top: 5px;
    font-size: 0.85rem;
    color: #666;
    text-align: right;
}

/* Clicked State for Buttons */
.clicked {
    pointer-events: none;
    opacity: 0.8;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        padding: 15px;
    }
    
    .candidates-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .user-info {
        flex-direction: column;
        width: 100%;
    }

    .user-info .btn {
        width: 100%;
        text-align: center;
    }

    .hero-section {
        padding: 40px 15px;
    }
    
    .hero-section h2 {
        font-size: 2rem;
    }

    .cta-buttons {
        flex-direction: column;
        gap: 15px;
    }

    .cta-buttons .btn {
        width: 100%;
    }

    .candidates-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .report-actions {
        flex-direction: column;
    }
    
    .report-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .candidate-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .stats-table {
        font-size: 14px;
    }
    
    .stats-table th,
    .stats-table td {
        padding: 10px;
    }
    
    .vote-count {
        font-size: 1.2rem;
    }
    
    .chart-container {
        padding: 20px;
        width: 95%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .form-container,
    .admin-section {
        padding: 20px;
    }

    .candidate-photo {
        width: 120px;
        height: 120px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .hero-section h2 {
        font-size: 1.6rem;
    }
    
    .hero-section p {
        font-size: 1rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .progress {
        font-size: 0.8rem;
        padding-right: 8px;
    }
}

/* Print Styles */
@media print {
    .btn,
    .user-info,
    .back-link,
    .report-actions,
    .search-input,
    .close-btn {
        display: none !important;
    }

    body {
        background: white;
        padding: 20px;
    }

    .container {
        max-width: 100%;
        padding: 0;
        margin: 0;
    }

    .header,
    .candidate-card,
    .admin-section,
    .stats-table {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }
    
    .stats-table {
        border-collapse: collapse;
    }
    
    .stats-table th {
        background: #f0f0f0;
        color: black;
    }
    
    .progress-bar {
        border: 1px solid #ddd;
    }
    
    .progress {
        background: #f0f0f0;
        color: black;
    }
    
    .vote-bars {
        background: none;
        border: 1px solid #ddd;
    }
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Tooltip */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]:before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    background: var(--primary-color);
    color: white;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 10;
}

[data-tooltip]:hover:before {
    opacity: 1;
    visibility: visible;
    bottom: 120%;
}

/* Additional Styles for Role-based System */

/* Role Sections */
.role-section {
    margin-bottom: 40px;
    background: white;
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--box-shadow);
}

.role-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--light-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.role-header h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin: 0;
}

.role-description {
    color: #666;
    font-size: 1rem;
    margin: 5px 0 0;
}

/* Candidates Row */
.candidates-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

/* Candidate Cards */
.candidate-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    border: 1px solid #eee;
}

.candidate-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

.candidate-card.disabled {
    opacity: 0.7;
    pointer-events: none;
    background: #f9f9f9;
}

.candidate-manifesto {
    margin: 15px 0;
    padding: 10px;
    background: var(--light-bg);
    border-radius: var(--border-radius);
    font-size: 0.95rem;
}

.candidate-manifesto strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 5px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.badge-success {
    background: var(--success-color);
    color: white;
}

/* Vote Progress */
.vote-progress {
    margin: 0 15px;
    min-width: 150px;
}

.vote-progress span {
    font-size: 0.9rem;
    color: #666;
}

.progress-bar-small {
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    margin-top: 5px;
    overflow: hidden;
}

.progress-small {
    height: 100%;
    background: var(--success-color);
    transition: width 0.3s ease;
}

/* Role Results */
.role-results {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--light-bg);
    border-radius: var(--border-radius);
}

.role-results h3 {
    color: var(--primary-color);
    margin-bottom: 5px;
}

.role-meta {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

/* Form Row */
.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-group.half {
    flex: 1;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .role-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .candidates-row {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .vote-progress {
        margin: 10px 0;
        width: 100%;
    }
}

/* Print Styles for Reports */
@media print {
    .role-section {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .candidates-row {
        display: block;
    }
    
    .candidate-card {
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 20px;
    }
}