/* ================================
   Votee - Danish Voting Application
   ================================ */

/* Variables */
:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #6B7280;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;

    --ja-color: #10B981;
    --maske-color: #F59E0B;
    --nej-color: #EF4444;

    --bg: #F9FAFB;
    --bg-white: #FFFFFF;
    --text: #111827;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --border-focus: #4F46E5;

    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base */
html {
    font-size: 16px;
    line-height: 1.5;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Container */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Header */
.site-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.main-nav {
    display: flex;
    gap: 1.5rem;
}

.main-nav a {
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.2s;
}

.main-nav a:hover {
    color: var(--primary);
    text-decoration: none;
}

/* Main */
.site-main {
    flex: 1;
    padding: 2rem 0;
}

/* Footer */
.site-footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 1.5rem;
}

.flash {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.flash-success {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.flash-error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.flash-warning {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FDE68A;
}

.flash-info {
    background: #DBEAFE;
    color: #1E40AF;
    border: 1px solid #BFDBFE;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover {
    background: #D97706;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1.125rem;
}

/* Forms */
.poll-form,
.vote-form,
.respond-form {
    background: var(--bg-white);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

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

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-help {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.form-check input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
}

.form-fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-fieldset legend {
    font-weight: 600;
    padding: 0 0.5rem;
}

.form-actions {
    margin-top: 2rem;
}

/* Option rows for poll creation */
.option-row,
.slot-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.option-row input,
.slot-row input {
    flex: 1;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.slot-row input[type="date"] {
    flex: 2;
}

.slot-row input[type="time"] {
    flex: 1;
}

.btn-remove-option,
.btn-remove-slot {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--danger);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-remove-option:hover:not(:disabled),
.btn-remove-slot:hover:not(:disabled) {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-remove-option:disabled,
.btn-remove-slot:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Home page */
.hero {
    text-align: center;
    padding: 3rem 0;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
}

.poll-type-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.poll-type-card {
    background: var(--bg-white);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.2s, box-shadow 0.2s;
}

.poll-type-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
}

.poll-type-icon {
    color: var(--primary);
    margin-bottom: 1rem;
}

.poll-type-card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.poll-type-card p {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.poll-type-cta {
    color: var(--primary);
    font-weight: 500;
}

/* Features section */
.features {
    margin-top: 4rem;
    text-align: center;
}

.features h2 {
    margin-bottom: 2rem;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.feature {
    padding: 1.5rem;
}

.feature h3 {
    margin-bottom: 0.5rem;
}

.feature p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Page header */
.page-header {
    text-align: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-muted);
}

/* Poll page */
.poll-page {
    background: var(--bg-white);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.poll-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.poll-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.poll-description {
    color: var(--text-muted);
}

.poll-footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.poll-actions {
    text-align: center;
    margin-top: 2rem;
}

/* Options list for voting */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.option-item:hover {
    border-color: var(--primary);
}

.option-item input[type="radio"] {
    width: 1.25rem;
    height: 1.25rem;
}

.option-item input[type="radio"]:checked + .option-text {
    color: var(--primary);
    font-weight: 500;
}

/* Results */
.results-section {
    margin-top: 2rem;
}

.total-votes,
.total-participants {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.results-bars {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-item {
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
}

.result-item.result-winner {
    background: #D1FAE5;
}

.result-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.result-text {
    font-weight: 500;
}

.result-count {
    color: var(--text-muted);
}

.result-bar-container {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.result-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.result-winner .result-bar {
    background: var(--success);
}

/* Success page */
.success-page {
    text-align: center;
    background: var(--bg-white);
    padding: 3rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.success-icon {
    color: var(--success);
    margin-bottom: 1.5rem;
}

.success-page h1 {
    margin-bottom: 0.5rem;
}

.success-page .lead {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.share-links {
    margin: 2rem 0;
    text-align: left;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.share-links h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    text-align: center;
}

.share-link-group {
    margin-bottom: 1rem;
}

.share-link-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
}

.copy-field {
    display: flex;
    gap: 0.5rem;
}

.copy-field input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--bg);
}

.admin-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--bg);
    border-radius: var(--radius);
    text-align: left;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.admin-section h2 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.warning-box {
    margin-top: 1rem;
    padding: 1rem;
    background: #FEF3C7;
    border: 1px solid #FDE68A;
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: #92400E;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-open {
    background: #D1FAE5;
    color: #065F46;
}

.status-closed {
    background: #FEE2E2;
    color: #991B1B;
}

.status-finalized {
    background: #DBEAFE;
    color: #1E40AF;
}

/* Dashboard */
.dashboard-page {
    background: var(--bg-white);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.poll-info {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.poll-info h2 {
    margin-bottom: 0.5rem;
}

.poll-meta {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.dashboard-section {
    padding: 1.5rem;
    background: var(--bg);
    border-radius: var(--radius);
}

.dashboard-section.full-width {
    grid-column: 1 / -1;
}

.dashboard-section h3 {
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

.dashboard-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.inline-form {
    display: inline;
}

/* Voters table */
.voters-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.voters-table th,
.voters-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.voters-table th {
    font-weight: 600;
    background: var(--bg-white);
}

/* Planlægning specific */
.response-grid,
.matrix-grid {
    overflow-x: auto;
}

.response-header,
.matrix-header {
    display: flex;
    background: var(--bg);
    font-weight: 600;
    font-size: 0.875rem;
}

.response-row,
.matrix-row {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.response-cell,
.matrix-cell {
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slot-cell,
.name-cell {
    flex: 2;
    min-width: 180px;
    justify-content: flex-start;
}

.header-cell {
    background: var(--bg);
}

.slot-header {
    flex: 1;
    min-width: 120px;
    font-size: 0.75rem;
    text-align: center;
}

.response-option {
    flex: 0 0 80px;
}

.response-indicator {
    display: block;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s;
}

.response-indicator.ja {
    background: #D1FAE5;
    color: #065F46;
}

.response-indicator.maske {
    background: #FEF3C7;
    color: #92400E;
}

.response-indicator.nej {
    background: #FEE2E2;
    color: #991B1B;
}

input[type="radio"]:checked + .response-indicator.ja {
    background: var(--ja-color);
    color: white;
}

input[type="radio"]:checked + .response-indicator.maske {
    background: var(--maske-color);
    color: white;
}

input[type="radio"]:checked + .response-indicator.nej {
    background: var(--nej-color);
    color: white;
}

.response-row label {
    cursor: pointer;
}

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

/* Matrix response cells */
.matrix-cell.response-cell {
    flex: 1;
    min-width: 120px;
    font-size: 0.875rem;
}

.matrix-cell.ja {
    background: #D1FAE5;
    color: #065F46;
}

.matrix-cell.maske {
    background: #FEF3C7;
    color: #92400E;
}

.matrix-cell.nej {
    background: #FEE2E2;
    color: #991B1B;
}

.totals-row {
    font-weight: 600;
    background: var(--bg);
}

/* Slot summary */
.slot-summary {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.slot-item {
    padding: 1rem;
    background: var(--bg-white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.slot-item.best-slot {
    border-color: var(--ja-color);
    background: #D1FAE5;
}

.slot-item.finalized-slot {
    border-color: var(--primary);
    background: #EEF2FF;
}

.slot-time {
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.best-badge,
.finalized-badge {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-weight: 600;
}

.best-badge {
    background: var(--ja-color);
    color: white;
}

.finalized-badge {
    background: var(--primary);
    color: white;
}

.slot-counts {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
}

.slot-counts .count {
    font-weight: 500;
}

.slot-counts .ja {
    color: #065F46;
}

.slot-counts .maske {
    color: #92400E;
}

.slot-counts .nej {
    color: #991B1B;
}

/* Finalized notice */
.finalized-notice {
    margin-top: 1rem;
    padding: 1rem;
    background: #EEF2FF;
    border: 1px solid #C7D2FE;
    border-radius: var(--radius);
    color: #3730A3;
}

.finalized-slot {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #EEF2FF;
    border-radius: var(--radius);
}

.selected-time {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

/* Finalize form */
.finalize-form {
    padding: 1.5rem;
    background: var(--bg-white);
    border-radius: var(--radius);
    margin-top: 1rem;
}

/* Results hidden */
.results-hidden {
    text-align: center;
    padding: 2rem;
    background: var(--bg);
    border-radius: var(--radius);
    color: var(--text-muted);
}

/* Error pages */
.error-page {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-content {
    text-align: center;
    padding: 2rem;
}

.error-content h1 {
    font-size: 6rem;
    color: var(--primary);
    line-height: 1;
}

.error-content h2 {
    margin: 1rem 0;
}

.error-content p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Loading state */
.loading-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.loading-state p {
    font-size: 1.125rem;
}

/* Already voted */
.already-voted {
    text-align: center;
    padding: 2rem;
}

.already-voted-icon {
    color: var(--success);
    margin-bottom: 1rem;
}

.already-voted h2 {
    margin-bottom: 0.5rem;
}

.already-voted p {
    color: var(--text-muted);
}

.already-voted-actions {
    margin-top: 1.5rem;
}

.results-note {
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Cloudflare Turnstile */
.cf-turnstile {
    margin: 1.5rem 0;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 1.75rem;
    }

    .poll-form,
    .vote-form,
    .respond-form,
    .poll-page,
    .success-page,
    .dashboard-page {
        padding: 1.5rem;
    }

    .option-row,
    .slot-row {
        flex-wrap: wrap;
    }

    .slot-row input[type="date"],
    .slot-row input[type="time"] {
        flex: 1 1 100%;
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .response-grid,
    .matrix-grid {
        font-size: 0.875rem;
    }

    .slot-cell,
    .name-cell {
        min-width: 120px;
    }

    .slot-header,
    .matrix-cell.response-cell {
        min-width: 80px;
    }

    .response-option {
        flex: 0 0 60px;
    }

    .response-indicator {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .site-header .container {
        flex-direction: column;
        text-align: center;
    }

    .main-nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .copy-field {
        flex-direction: column;
    }

    .copy-field .btn {
        width: 100%;
    }
}
