* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    animation: slideUp 0.3s ease;
}

.modal-content.large {
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: #333;
}

/* Login Form */
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h2 {
    color: #333;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: #666;
    font-size: 0.9rem;
}

/* Dashboard Layout */
.dashboard {
    display: none;
    min-height: 100vh;
}

.dashboard.active {
    display: block;
}

/* Header */
.admin-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 0;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 900;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: 80px;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h2 {
    font-size: 1.8rem;
    font-weight: bold;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.hamburger-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

.welcome-text {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 80px;
    width: 250px;
    height: calc(100vh - 80px);
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    z-index: 800;
    transition: transform 0.3s ease;
}

.sidebar-nav {
    flex: 1;
    padding: 2rem 0;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 1rem 2rem;
    text-decoration: none;
    color: #666;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.nav-item:hover,
.nav-item.active {
    background: #f8f9fa;
    color: #667eea;
    border-left-color: #667eea;
}

.nav-item i {
    margin-right: 1rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 2rem;
    border-top: 1px solid #eee;
}

/* Main Content */
.main-content {
    margin-left: 250px;
    margin-top: 80px;
    padding: 2rem;
    min-height: calc(100vh - 80px);
}

/* Admin Sections */
.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.section-header h1 {
    font-size: 2rem;
    color: #333;
    margin: 0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-icon {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1.5rem;
}

.stat-icon i {
    font-size: 1.5rem;
}

.stat-content h3 {
    font-size: 2rem;
    color: #333;
    margin-bottom: 0.5rem;
}

.stat-content p {
    color: #666;
    font-size: 0.9rem;
}

/* Content Tables */
.content-table {
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

tr:hover {
    background: #f8f9fa;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    min-height: 44px;
    min-width: 44px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-outline {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 36px;
    min-width: 36px;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Messages */
.error-message {
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 1rem;
    display: none;
}

.error-message.active {
    display: block;
}

.success-message {
    color: #155724;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 1rem;
    display: none;
}

.success-message.active {
    display: block;
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    text-align: center;
}

.spinner i {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 1rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(30px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    .hamburger-btn {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
        z-index: 999;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 1rem;
        margin-top: 80px;
    }
    
    .header-content {
        padding: 0 1rem;
    }
    
    .section-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .section-header h1 {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .modal-content {
        width: 95%;
        padding: 1rem;
        margin: 1rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    /* Table Responsive */
    .content-table {
        overflow-x: auto;
        border-radius: 10px;
    }
    
    table {
        min-width: 600px;
        font-size: 0.875rem;
    }
    
    th, td {
        padding: 0.75rem 0.5rem;
        white-space: nowrap;
    }
    
    /* Action buttons in tables */
    td:last-child {
        white-space: nowrap;
        min-width: 120px;
    }
    
    td:last-child .btn {
        margin: 0.25rem;
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        min-width: 32px;
        min-height: 32px;
    }
    
    /* Button adjustments for mobile */
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        min-height: 44px;
    }
    
    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        min-height: 36px;
    }
    
    /* Hide welcome text on mobile */
    .welcome-text {
        display: none;
    }
    
    /* Poll options mobile improvements */
    .poll-option {
        margin-bottom: 1rem;
    }
    
    .poll-option .btn {
        min-width: 40px;
        min-height: 40px;
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .stat-card {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem;
    }
    
    .stat-icon {
        margin-right: 0;
        margin-bottom: 1rem;
    }
    
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        width: 100%;
    }
    
    .section-header .btn {
        width: 100%;
    }
    
    .modal-content {
        width: 98%;
        padding: 1rem;
        margin: 0.5rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Table improvements for very small screens */
    table {
        min-width: 500px;
        font-size: 0.8rem;
    }
    
    th, td {
        padding: 0.5rem 0.25rem;
    }
    
    /* Stack action buttons vertically on very small screens */
    td:last-child {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        min-width: 80px;
    }
    
    td:last-child .btn {
        width: 100%;
        margin: 0;
        padding: 0.4rem;
        font-size: 0.7rem;
    }
}

/* Sidebar overlay for mobile */
@media (max-width: 768px) {
    .sidebar::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: -1;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .sidebar.active::before {
        opacity: 1;
        visibility: visible;
    }
}

/* Additional improvements for polls section */
.poll-option {
    position: relative;
}

.poll-option .btn-danger {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.poll-option .btn-danger:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* Form improvements for mobile */
@media (max-width: 768px) {
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group label {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 0.6rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .form-group textarea {
        min-height: 80px;
    }
    
    /* Poll options mobile layout */
    .poll-option > div {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .poll-option input {
        width: 100%;
    }
    
    .poll-option .btn-danger {
        align-self: flex-end;
        margin-top: 0.25rem;
    }
    
    /* Action buttons in tables */
    td:last-child {
        white-space: nowrap;
        min-width: 120px;
    }
    
    td:last-child .btn {
        margin: 0.25rem;
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
        min-width: 32px;
        min-height: 32px;
    }
}

/* Loading spinner improvements for mobile */
@media (max-width: 768px) {
    .spinner i {
        font-size: 2rem;
    }
    
    .spinner p {
        font-size: 0.9rem;
    }
}

/* Table improvements for very small screens */
@media (max-width: 480px) {
    /* Stack action buttons vertically on very small screens */
    td:last-child {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        min-width: 80px;
    }
    
    td:last-child .btn {
        width: 100%;
        margin: 0;
        padding: 0.4rem;
        font-size: 0.7rem;
    }
}
