/* ===== CSS Variables ===== */
:root {
    --primary: #25D366;
    --primary-dark: #128C7E;
    --secondary: #34B7F1;
    --danger: #DC3545;
    --warning: #FFC107;
    --success: #28A745;
    --dark: #2C3E50;
    --light: #ECF0F1;
    --white: #FFFFFF;
    --gray: #95A5A6;
    --gray-light: #BDC3C7;
    --border: #E0E0E0;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 5px 20px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --transition: all 0.3s ease;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark);
    line-height: 1.6;
}

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.header {
    background: var(--white);
    padding: 10px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
}

.logo h1 a {
    text-decoration: none;
    color: var(--dark);
    transition: var(--transition);
}

.logo h1 a:hover {
    color: var(--primary);
}

.nav {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.nav a {
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--dark);
    font-weight: 500;
    transition: var(--transition);
    background: var(--light);
}

.nav a:hover,
.nav a.active {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-2px);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

/* ===== Welcome Section ===== */
.welcome-section {
    text-align: center;
    margin-bottom: 20px;
}

.welcome-section h2 {
    font-size: 36px;
    color: var(--dark);
    margin-bottom: 10px;
}

.welcome-section p {
    font-size: 18px;
    color: var(--gray);
    margin-bottom: 10px;
}

.stats-mini {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.stats-mini span {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}

/* ===== Action Cards ===== */
.action-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.card {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    transition: var(--transition);
    text-decoration: none;
    color: var(--dark);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.card-create {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border: none;
}

.card-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.card h3 {
    font-size: 22px;
    margin-bottom: 10px;
}

.card p {
    color: var(--gray);
    font-size: 14px;
}

.card-create p {
    color: rgba(255, 255, 255, 0.9);
}

.join-form {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.join-form input {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    text-align: center;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 2px;
}

.join-form input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== Buttons ===== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    font-family: 'Poppins', sans-serif;
}

.btn-primary {
    background: #28a745;
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(37, 211, 102, 0.3);
}

.btn-secondary {
    background: var(--light);
    color: var(--dark);
}

.btn-secondary:hover {
    background: var(--gray-light);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #c82333;
}

.btn-sm {
    padding: 10px 16px;
    font-size: 14px;
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 18px;
}

/* ===== Recent Section ===== */
.recent-section {
    margin-top: 10px;
}

.recent-section h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #555;
    text-align: center;
}

.polls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.poll-card {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
}

.poll-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.poll-header {
    margin-bottom: 15px;
}

.poll-header h4 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    font-family: 'Anek Tamil', sans-serif;
    text-align: center;
}

.poll-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 14px;
    color: #555;
}

.poll-actions {
    display: flex;
    gap: 10px;
}

/* ===== Badges ===== */
.badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-active {
    background: var(--success);
    color: var(--white);
}

.badge-closed {
    background: var(--gray);
    color: var(--white);
}

/* ===== Form Styles ===== */
.form-container {
    max-width: 600px;
    margin: 0 auto;
}

.form-container h2 {
    font-size: 28px;
    margin-bottom: 30px;
    text-align: center;
}

.poll-form {
    background: var(--light);
    padding: 30px;
    border-radius: var(--radius);
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
}

.hint {
    font-weight: 400;
    color: var(--gray);
    font-size: 14px;
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Poppins', sans-serif;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

#optionsContainer {
    margin-bottom: 15px;
}

.option-input {
    position: relative;
    margin-bottom: 12px;
}

.option-input input {
    padding-right: 80px;
}

.option-number {
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary);
    color: var(--white);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.remove-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--danger);
    color: var(--white);
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    transition: var(--transition);
}

.remove-btn:hover {
    background: #c82333;
    transform: translateY(-50%) scale(1.1);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ===== Vote Form ===== */
.poll-view,
.results-view {
    max-width: 700px;
    margin: 0 auto;
}

.poll-header-info {
    text-align: center;
    margin-bottom: 10px;
}

.poll-header-info h2 {
    font-size: 18px;
    margin-bottom: 15px;
    line-height: 1.4;
    font-family: 'Anek Tamil', sans-serif;
}

.poll-code-display {
    display: inline-block;
    background: var(--primary);
    color: var(--white);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: 600;
}

.vote-form {
    background: var(--light);
    padding: 5px;
    border-radius: var(--radius);
    margin-bottom: 30px;
}

.vote-option {
    display: block;
    position: relative;
    padding: 18px 20px 18px 55px;
    margin-bottom: 12px;
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.vote-option:hover {
    border-color: var(--primary);
    transform: translateX(5px);
}

.vote-option input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.vote-option input:checked ~ .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.vote-option input:checked ~ .checkmark:after {
    display: block;
}

.option-text {
    font-size: 16px;
    font-weight: 500;
}

.checkmark {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    height: 24px;
    width: 24px;
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: 50%;
    transition: var(--transition);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 7px;
    top: 3px;
    width: 6px;
    height: 11px;
    border: solid var(--white);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ===== Alerts ===== */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-weight: 500;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    text-align: center;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    text-align: center;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.anonymous-alert {
    background-color: #d4edda; /* light green */
    color: #155724; /* dark green text */
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    padding: 8px 15px;
    font-size: 14px;
    font-weight: 600;
    margin-top: 10px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}


/* ===== Poll Stats ===== */
.poll-stats {
    display: flex;
    justify-content: center;
    gap: 25px;
    flex-wrap: wrap;
    padding: 20px;
    background: var(--light);
    border-radius: 10px;
    margin-top: 5px;
}

.poll-stats span {
    font-size: 14px;
    font-weight: 500;
    color: #555;
}

/* ===== Results Container ===== */
.results-container {
    margin-bottom: 5px;
}

.result-item {
    margin-bottom: 10px;
    padding: 5px 10px;
    background: var(--light);
    border-radius: 10px;
    transition: var(--transition);
}

.result-item.winning {
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.1), rgba(18, 140, 126, 0.1));
    border: 2px solid var(--primary);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
    gap: 15px;
}

.result-text {
    font-weight: 600;
    font-size: 16px;
    color: var(--dark);
    flex: 1;
    font-family: 'Anek Tamil', sans-serif;
}

.result-percentage {
    font-weight: 600;
    font-size: 22px;
    color: #06a542;
    white-space: nowrap;
}

.result-bar {
    height: 12px;
    background: #ccc;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 8px;
}

.result-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 20px;
    transition: width 1s ease-out;
}

.result-votes {
    font-size: 13px;
    color: #555;
    font-weight: 500;
    text-align: center;
}

/* ===== Share Section ===== */
.share-section {
    margin-top: 30px;
    padding: 25px;
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    border-radius: var(--radius);
    color: var(--white);
}

.share-section h3 {
    margin-bottom: 15px;
    font-size: 20px;
}

.share-link {
    display: flex;
    gap: 10px;
}

.share-link input {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Poppins', sans-serif;
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 10px;
    flex-wrap: wrap;
}

/* ===== Manage View ===== */
.manage-view h2 {
    font-size: 28px;
    margin-bottom: 30px;
    text-align: center;
}

.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.polls-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
}

.polls-table thead {
    background: var(--primary);
    color: var(--white);
}

.polls-table th,
.polls-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.polls-table th {
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.polls-table tbody tr {
    transition: var(--transition);
}

.polls-table tbody tr:hover {
    background: var(--light);
}

.question-cell {
    max-width: 300px;
}

.actions-cell {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    transition: var(--transition);
    text-decoration: none;
}

.btn-icon:hover {
    transform: scale(1.2);
}

.btn-icon.btn-danger:hover {
    filter: brightness(0.8);
}

/* ===== Database View ===== */
.database-view h2 {
    font-size: 28px;
    margin-bottom: 30px;
    text-align: center;
}

.db-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.db-info-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--white);
    padding: 30px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.db-info-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.db-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.db-stats h3 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 5px;
}

.db-stats p {
    font-size: 14px;
    opacity: 0.9;
}

.db-connection-info {
    background: var(--light);
    padding: 25px;
    border-radius: var(--radius);
    margin-bottom: 30px;
}

.db-connection-info h3 {
    font-size: 20px;
    margin-bottom: 20px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.info-item {
    padding: 15px;
    background: var(--white);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.info-item strong {
    display: block;
    margin-bottom: 5px;
    color: var(--gray);
    font-size: 13px;
}

.info-item code {
    background: var(--light);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.db-structure {
    background: var(--light);
    padding: 25px;
    border-radius: var(--radius);
    margin-bottom: 30px;
}

.db-structure h3 {
    font-size: 20px;
    margin-bottom: 20px;
}

.tables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.table-info {
    background: var(--white);
    padding: 20px;
    border-radius: 8px;
    border-top: 4px solid var(--primary);
}

.table-info h4 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--primary);
}

.table-info ul {
    list-style: none;
}

.table-info li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-family: 'Courier New', monospace;
}

.table-info li:last-child {
    border-bottom: none;
}

.db-actions {
    background: var(--light);
    padding: 25px;
    border-radius: var(--radius);
    text-align: center;
}

.db-actions h3 {
    font-size: 20px;
    margin-bottom: 20px;
}

.warning-text {
    margin-top: 15px;
    color: var(--danger);
    font-size: 14px;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--light);
    border-radius: var(--radius);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-state p {
    font-size: 18px;
    color: var(--gray);
    margin-bottom: 20px;
}

/* ===== Error View ===== */
.error-view {
    text-align: center;
    padding: 80px 20px;
}

.error-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.error-view h2 {
    font-size: 32px;
    margin-bottom: 15px;
}

.error-view p {
    font-size: 18px;
    color: var(--gray);
    margin-bottom: 30px;
}

/* ===== Toast Notification ===== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--dark);
    color: var(--white);
    padding: 16px 30px;
    border-radius: 12px; /* optional smaller radius */
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    font-weight: 500;
    min-width: 300px;
    text-align: center;
}

.toast.show {
    opacity: 1;
    pointer-events: auto;
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

.toast-info {
    background: var(--secondary);
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--white);
    margin-top: 30px;
    font-size: 14px;
}

.footer p {
    margin: 5px 0;
    opacity: 0.9;
}

.footer strong {
    color: var(--primary);
}

/* ===== Anek Tamil Font for Questions and Options ===== */
.poll-header h4,
.poll-header-info h2,
.option-text,
.result-text,
.vote-option,
.welcome-section h2 {
    font-family: 'Anek Tamil', 'Poppins', sans-serif;
}

/* ===== Poll Card Improvements ===== */
.poll-card {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    min-height: 200px; /* Fixed minimum height */
}

.poll-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.poll-header {
    margin-bottom: 15px;
    text-align: center; /* Center align content */
    flex-grow: 1; /* Allow to grow */
    display: flex;
    align-items: center;
    justify-content: center;
}

.poll-header h4 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* Show 3 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 67px; /* Fixed height for 3 lines (16px * 1.4 * 3 ≈ 67px) */
    margin: 0;
}

.poll-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 14px;
    color: #555;
    justify-content: center; /* Center align meta */
}

.poll-actions {
    display: flex;
    gap: 10px;
    justify-content: center; /* Center align actions */
    margin-top: auto; /* Push to bottom */
}

/* ===== Responsive adjustments for poll cards ===== */
@media (max-width: 480px) {
.poll-card {
        padding: 20px; /* Increased from 15px */
    }

    .poll-header h4 {
        font-size: 16px; /* Increased from 14px */
    }

    .poll-meta {
        font-size: 14px; /* Increased from 12px */
        gap: 12px; /* Increased from 10px */
    }

    .btn-sm {
        padding: 10px 16px; /* Increased from 6px 12px */
        font-size: 14px; /* Increased from 12px */
    }
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header {
        padding: 10px;
        flex-direction: column;
        align-items: stretch;
    }

    .logo {
        justify-content: center;
    }

    .nav {
        justify-content: center;
    }

    .nav a {
        flex: 1;
        text-align: center;
        padding: 10px;
        font-size: 14px;
    }

    .main-content {
        padding: 10px;
    }

    .welcome-section h2 {
        font-size: 28px;
    }

    .welcome-section p {
        font-size: 16px;
    }

    .action-cards {
        grid-template-columns: 1fr;
    }

    .polls-grid {
        grid-template-columns: 1fr;
    }

    .poll-header-info h2 {
        font-size: 18px;
        margin-bottom: 10px;
    }

    .share-link {
        flex-direction: column;
    }

    .db-info-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .tables-grid {
        grid-template-columns: 1fr;
    }

    .polls-table {
        font-size: 13px;
    }

    .polls-table th,
    .polls-table td {
        padding: 10px;
    }

    .question-cell {
        max-width: 150px;
    }

    .stats-mini {
        flex-direction: column;
        gap: 10px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
    }

    .join-card {
        padding: 30px 20px;
    }

    .join-form-main input,
    .join-form-main button {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 22px;
    }

    .welcome-section h2 {
        font-size: 24px;
    }

    .card-icon {
        font-size: 36px;
    }

    .db-info-grid {
        grid-template-columns: 1fr;
    }

    .db-icon {
        font-size: 36px;
    }

    .db-stats h3 {
        font-size: 28px;
    }

    .toast {
        min-width: 250px;
        padding: 12px 20px;
        font-size: 14px;
    }

    .polls-table {
        min-width: 600px;
    }

    .join-card {
        padding: 25px 15px;
    }

    .join-form-main input {
        padding: 12px;
        font-size: 16px;
    }

    .result-percentage {
        font-size: 18px;
    }

    .result-text {
        font-size: 14px;
    }

    .poll-card {
        padding: 15px;
    }

    .poll-header h4 {
        font-size: 16px;
    }

    .poll-meta {
        font-size: 14px;
        gap: 10px;
    }

    .btn-sm {
        padding: 10px 16px;
        font-size: 14px;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.poll-card,
.result-item,
.db-info-card {
    animation: fadeIn 0.5s ease-out;
}

/* ===== Print Styles ===== */
@media print {
    .header,
    .nav,
    .footer,
    .action-buttons,
    .share-section,
    .db-actions {
        display: none;
    }

    .main-content {
        box-shadow: none;
                padding: 0;
    }

    body {
        background: white;
    }
}

/* ===== Accessibility ===== */
.btn:focus,
.vote-option:focus-within,
input:focus,
textarea:focus {
    outline: 3px solid green;
    outline-offset: 2px;
}

/* ===== Loading State ===== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--white);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { 
        transform: rotate(360deg); 
    }
}

/* ===== Custom Scrollbar ===== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--light);
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* ===== Login Page Styles ===== */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
}

.login-box {
    background: var(--white);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 100%;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 28px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Poppins', sans-serif;
}

.login-form input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== Admin Button Style ===== */
.btn-admin {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--white) !important;
}

.btn-logout {
    background: var(--danger) !important;
    color: var(--white) !important;
}

/* ===== Join Poll Section ===== */
.join-poll-section {
    margin: 40px 0;
    display: flex;
    justify-content: center;
}

.join-card {
    background: linear-gradient(135deg, var(--secondary) 0%, #667eea 100%);
    color: var(--white);
    padding: 40px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
}

.join-card h3 {
    margin-bottom: 20px;
    font-size: 24px;
}

.join-form-main {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.join-form-main input {
    width: 100%;
    max-width: 300px;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    text-align: center;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 3px;
}

.join-form-main input:focus {
    outline: 3px solid rgba(255, 255, 255, 0.5);
}

.join-form-main button {
    width: 100%;
    max-width: 300px;
}

/* ===== Admin Dashboard ===== */
.admin-dashboard h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 28px;
}

/* ===== Ensure all cards fit properly ===== */
.card,
.poll-card,
.db-info-card,
.join-card {
    max-width: 100%;
    overflow: hidden;
    word-wrap: break-word;
}

.poll-header h4,
.result-text,
.option-text {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* ===== Additional Styles for Updated Features ===== */

/* Form Select Dropdown */
.form-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Poppins', sans-serif;
    background-color: var(--white);
    cursor: pointer;
    transition: var(--transition);
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-select option {
    padding: 10px;
}

/* Poll Instruction */
.poll-instruction {
    text-align: center;
    color: #28a745;
    font-size: 14px;
    margin-top: 10px;
}

/* Poll Info Badges */
.poll-info-badges {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 20px 0;
}

.badge-info {
    background: var(--secondary);
    color: var(--white);
}

/* Settings View */
.settings-view h2 {
    font-size: 28px;
    margin-bottom: 30px;
    text-align: center;
}

.settings-section {
    background: var(--light);
    padding: 30px;
    border-radius: var(--radius);
    margin-bottom: 30px;
}

.settings-section h3 {
    font-size: 22px;
    margin-bottom: 20px;
    color: var(--dark);
}

/* Restriction Form */
.restriction-form {
    margin-top: 20px;
}

.restriction-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.restriction-option {
    cursor: pointer;
}

.restriction-option input[type="radio"] {
    display: none;
}

.restriction-card {
    background: var(--white);
    border: 3px solid var(--border);
    border-radius: var(--radius);
    padding: 25px;
    text-align: center;
    transition: var(--transition);
    height: 100%;
}

.restriction-option input[type="radio"]:checked + .restriction-card {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.1), rgba(18, 140, 126, 0.1));
    box-shadow: var(--shadow-lg);
}

.restriction-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.restriction-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.restriction-card h4 {
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--dark);
}

.restriction-card p {
    font-size: 14px;
    color: var(--gray);
    line-height: 1.5;
}

/* Enhanced Table Styles */
.polls-table th:nth-child(4),
.polls-table td:nth-child(4) {
    text-align: center;
}

/* Responsive Adjustments for New Features */
@media (max-width: 768px) {
    .restriction-options {
        grid-template-columns: 1fr;
    }
    
    .poll-info-badges {
        flex-direction: column;
        align-items: center;
    }
    
    .settings-section {
        padding: 20px;
    }
    
    .restriction-card {
        padding: 20px;
    }
    
    .restriction-icon {
        font-size: 36px;
    }
}

@media (max-width: 480px) {
    .form-select {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .restriction-card h4 {
        font-size: 16px;
    }
    
    .restriction-card p {
        font-size: 13px;
    }
}

/* Enhanced Badge Styles */
.badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

/* Loading State for Forms */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Better Focus States */
.restriction-option:focus-within .restriction-card {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Smooth Transitions */
.restriction-card,
.form-select,
.vote-option {
    transition: all 0.3s ease;
}

/* Enhanced Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--light);
    border-radius: var(--radius);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: fadeIn 0.5s ease-out;
}

/* Print Styles Enhancement */
@media print {
    .restriction-options,
    .db-actions,
    .settings-section {
        display: none;
    }
}

/* ===== Advertisement Cards ===== */
.ads-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--border);
}

.ads-section h4 {
    text-align: center;
    font-size: 16px;
    color: var(--gray);
    margin-bottom: 15px;
    font-weight: 500;
}

.ads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.ad-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 12px;
    padding: 20px;
    text-decoration: none;
    color: var(--dark);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.ad-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
}

.ad-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Individual card colors */
.ad-card.bible-app {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--white);
}

.ad-card.bible-game {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: var(--white);
}

.ad-card.whatsapp-group {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: var(--white);
}

.ad-icon {
    font-size: 48px;
    flex-shrink: 0;
    animation: float 3s ease-in-out infinite;
}

.ad-content {
    flex: 1;
}

.ad-content h5 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
    font-family: 'Poppins', sans-serif;
}

.ad-content p {
    font-size: 13px;
    opacity: 0.9;
    line-height: 1.4;
}

.ad-arrow {
    font-size: 24px;
    flex-shrink: 0;
    transition: var(--transition);
}

.ad-card:hover .ad-arrow {
    transform: translateX(5px);
}

/* Float animation for icons */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .ads-grid {
        grid-template-columns: 1fr;
    }
    
    .ad-card {
        padding: 15px;
    }
    
    .ad-icon {
        font-size: 40px;
    }
    
    .ad-content h5 {
        font-size: 16px;
    }
    
    .ad-content p {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .ad-icon {
        font-size: 36px;
    }
    
    .ad-content h5 {
        font-size: 16px;
    }
}

.visibility-indicator {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    background: #f0f0f0;
}

.badge-closed {
    background: #6c757d;
    color: white;
}

/* ===== Media Upload Styles ===== */
.file-input {
    width: 100%;
    padding: 12px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    background: var(--white);
}

.file-input:hover {
    border-color: var(--primary);
    background: var(--light);
}

.media-preview {
    margin-top: 15px;
    border-radius: 8px;
    overflow: hidden;
    max-width: 100%;
}

.media-preview img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

.media-preview audio {
    width: 100%;
    margin: 10px 0;
}

.media-preview video {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

/* ===== Poll Media Display ===== */
.poll-media-container {
    margin-bottom: 25px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    background: var(--light);
}

.poll-media-container img {
    width: 100%;
    height: auto;
    max-height: 400px;
    object-fit: contain;
    display: block;
    background: var(--white);
}

.poll-media-container audio {
    width: 100%;
    padding: 15px;
    background: var(--white);
}

.poll-media-container video {
    width: 100%;
    max-height: 500px;
    display: block;
    background: #000;
}

/* Responsive media */
@media (max-width: 768px) {
    .poll-media-container img {
        max-height: 300px;
    }
    
    .poll-media-container video {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .poll-media-container img {
        max-height: 250px;
    }
    
    .poll-media-container video {
        max-height: 250px;
    }
}