/* ============================================================================
   PROJEKTTILMELDING - styles.css
   ============================================================================ */

:root {
    --primary-color:   hsl(175, 47%, 18%);
    --primary-hover:   hsl(175, 47%, 12%);
    --success-color:   hsl(113, 55%, 36%);
    --success-light:   hsl(113, 55%, 96%);
    --danger-color:    hsl(5, 75%, 50%);
    --danger-light:    hsl(5, 100%, 96%);
    --light-gray:      #f5f6f8;
    --border-color:    #dde1e7;
    --text-color:      #1e2229;
    --text-muted:      #6b7280;
    --aspit-red:       hsl(5, 100%, 64%);
    --aspit-white:     #fff;

    --hue:               175;
    --saturation-value:  47;
    --saturation:        calc(var(--saturation-value) * 1%);
    --aspit-night-green: hsl(var(--hue), var(--saturation), 12%);

    --radius:    8px;
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.07);
    --shadow-md: 0 3px 12px rgba(0,0,0,0.09);
    --shadow-lg: 0 8px 28px rgba(0,0,0,0.11);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    line-height: 1.55;
    color: var(--text-color);
    background: var(--light-gray);
    padding-top: 3rem;
}

/* ============================================================================
   ASPIT PAGE-HEADER
   ============================================================================ */
.page-header {
    height: 3rem;
    position: fixed;
    z-index: 50;
    top: 0; left: 0; right: 0;
    background: var(--aspit-night-green);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    color: var(--aspit-white);
}
.site-title {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.4);
    font-weight: 600;
}
.site-title:last-of-type { text-align: right; }

.site-logo {
    width: 4rem; height: 4rem;
    border-radius: 50%;
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem;
    background: var(--aspit-night-green);
}
.site-logo svg { width: 100%; height: 100%; }
.white-fill { fill: var(--aspit-white); }
.red-fill   { fill: var(--aspit-red); }

/* ============================================================================
   APP HEADER
   ============================================================================ */
.header {
    background: var(--primary-color);
    color: white;
    padding: 1.5rem 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.header h1   { font-size: 1.8rem; font-weight: 700; }
.subtitle    { font-size: 0.92rem; opacity: 0.8; margin-top: 0.2rem; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.main-content {
    padding: 2rem 0 3rem;
    min-height: calc(100vh - 200px);
}

/* ============================================================================
   PRINT-ONLY HEADER
   ============================================================================ */
.print-only { display: none; }

.print-header {
    padding: 0 0 1rem;
    border-bottom: 2pt solid #333;
    margin-bottom: 1.2rem;
}
.print-header h1 { font-size: 16pt; }
.print-date      { font-size: 9pt; color: #555; margin-top: 0.3rem; }

/* ============================================================================
   PROJEKT-KORT
   Top-række:  [Projektnavn] ........... [−] [12] [+]  [✏️] [🗑]
   Bund-sektion: deltager-tekstfelt
   ============================================================================ */
   
#polls-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 2rem;
}
.poll-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow 0.15s;
}
.poll-card:hover { box-shadow: var(--shadow-md); }

/* Øverste række */
.poll-card-top {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--border-color);
    background: hsl(175, 30%, 98%);
}

.poll-card-title-group {
    flex: 1;
    min-width: 0;
}

.poll-card-title {
    font-size: 1.05rem;
    font-weight: 600;
}

.poll-card-description {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    line-height: 1.45;
}

.poll-card-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* ============================================================================
   DELTAGER-FELT (kollapsibel)
   ============================================================================ */
.participants-section {
    border-top: 1px solid var(--border-color);
}

/* Toggle-knap der fylder hele bredden */
.participants-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.13s;
}
.participants-toggle:hover { background: hsl(175, 30%, 97%); }

.participants-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    pointer-events: none;
}

.toggle-icon {
    font-size: 1.5rem;
    color: #000;
    transition: transform 0.18s ease;
    pointer-events: none;
    flex-shrink: 0;
}

.participants-toggle[aria-expanded="true"] .toggle-icon {
    transform: rotate(90deg);
}

/* Selve indholdet - hidden attribut styrer visibility */
.participants-wrap {
    padding: 0 1.1rem 0.85rem;
    animation: slideDown 0.18s ease;
}

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

.participants-input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-color);
    line-height: 1.55;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: var(--light-gray);
    min-height: 4.5rem;
}
.participants-input:focus {
    border-color: var(--primary-color);
    background: #fff;
    box-shadow: 0 0 0 3px hsl(175, 47%, 18%, 0.07);
}
.participants-input::placeholder { color: var(--text-muted); opacity: 0.55; }

.participants-status {
    font-size: 0.73rem;
    min-height: 1.1rem;
    margin-top: 0.2rem;
    color: var(--text-muted);
    padding: 0 1rem 1rem 1rem;
}
.participants-status.status-saved { color: var(--success-color); }
.participants-status.status-error { color: var(--danger-color); }

/* Print: toggle skjules, wrap vises altid */
.participants-print {
    display: none;
    font-size: 0.88rem;
    color: #333;
    line-height: 1.6;
}

/* +/- og tæller */
.counter-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-vote {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, background 0.12s;
    user-select: none;
    flex-shrink: 0;
}

.btn-plus {
    background: var(--success-color);
    color: #fff;
    box-shadow: 0 2px 5px hsl(113, 55%, 36%, 0.3);
}
.btn-plus:hover  { background: hsl(113, 55%, 28%); transform: scale(1.1); }
.btn-plus:active { transform: scale(0.92); }

.btn-minus {
    background: #fff;
    color: var(--text-muted);
    border: 2px solid var(--border-color);
}
.btn-minus:hover:not(:disabled) {
    background: var(--danger-light);
    color: var(--danger-color);
    border-color: var(--danger-color);
    transform: scale(1.1);
}
.btn-minus:active:not(:disabled) { transform: scale(0.92); }
.btn-minus:disabled { opacity: 0.28; cursor: not-allowed; }

.counter-value {
    font-size: 1.6rem;
    font-weight: 700;
    min-width: 2.2rem;
    text-align: center;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

/* Flash-animationer */
@keyframes flashUp {
    0%  { transform: scale(1);    color: inherit; }
    45% { transform: scale(1.4);  color: var(--success-color); }
    100%{ transform: scale(1);    color: inherit; }
}
@keyframes flashDown {
    0%  { transform: scale(1);    color: inherit; }
    45% { transform: scale(0.65); color: var(--danger-color); }
    100%{ transform: scale(1);    color: inherit; }
}
.flash-up   { animation: flashUp   0.28s ease; }
.flash-down { animation: flashDown 0.28s ease; }

/* Print-tæller (kun ved print) */
.counter-print { display: none; }

/* Rediger/slet knapper */
.poll-card-actions {
    display: flex;
    gap: 0.2rem;
    border-left: 1px solid var(--border-color);
    padding-left: 0.65rem;
}

.btn-icon-sm {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0.3rem 0.4rem;
    border-radius: 5px;
    color: var(--text-muted);
    transition: background 0.12s, color 0.12s;
    line-height: 1;
}
.btn-icon-sm:hover       { background: var(--light-gray); color: var(--text-color); }
.btn-icon-delete:hover   { background: var(--danger-light); color: var(--danger-color); }

/* ============================================================================
   EMPTY STATE / FEJL
   ============================================================================ */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: #fff;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
}
.empty-icon     { font-size: 2.8rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.3rem; margin-bottom: 0.4rem; }
.empty-state p  { color: var(--text-muted); margin-bottom: 1.5rem; }

.error-box {
    background: #fff;
    border-left: 4px solid var(--danger-color);
    border-radius: var(--radius);
    padding: 1.4rem;
    box-shadow: var(--shadow-sm);
}
.error-box h3   { color: var(--danger-color); margin-bottom: 0.4rem; }
.error-box code { background: var(--light-gray); padding: 0.1rem 0.35rem; border-radius: 3px; font-size: 0.85rem; }

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn-primary, .btn-secondary, .btn-print-page {
    padding: 0.58rem 1.2rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, transform 0.1s, box-shadow 0.12s;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}
.btn-primary {
    background: var(--aspit-red);
    color: #fff;
}
.btn-primary:hover { background: hsl(5, 100%, 56%); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-secondary {
    background: #fff;
    color: var(--text-color);
    border: 1.5px solid var(--border-color);
}
.btn-secondary:hover { background: var(--light-gray); }

.btn-print-page {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,0.35);
}
.btn-print-page:hover { background: rgba(255,255,255,0.25); transform: translateY(-1px); }

/* ============================================================================
   MODAL
   ============================================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
    animation: fadeIn 0.14s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    animation: slideUp 0.17s ease;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: none; }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.3rem 1.4rem 0;
}
.modal-header h2 { font-size: 1.2rem; }

.modal-close {
    background: none; border: none;
    font-size: 1.1rem; cursor: pointer;
    color: var(--text-muted); padding: 0.25rem 0.35rem;
    border-radius: 4px; transition: background 0.1s;
}
.modal-close:hover { background: var(--light-gray); color: var(--text-color); }

.modal-body   { padding: 1.1rem 1.4rem; }
.modal-footer { padding: 0 1.4rem 1.3rem; display: flex; gap: 0.65rem; justify-content: flex-end; }

/* ============================================================================
   FORM
   ============================================================================ */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.38rem;
}
.form-input {
    width: 100%;
    padding: 0.58rem 0.85rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    color: var(--text-color);
    outline: none;
    transition: border-color 0.14s;
}
.form-input:focus { border-color: var(--primary-color); }

.form-textarea {
    resize: vertical;
    min-height: 5rem;
    line-height: 1.55;
    font-family: inherit;
}

.form-label-optional {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    opacity: 0.8;
}

/* ============================================================================
   TOAST
   ============================================================================ */
.toast-container {
    position: fixed;
    bottom: 1.5rem; right: 1.5rem;
    z-index: 2000;
    display: flex; flex-direction: column; gap: 0.4rem;
}
.toast {
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-size: 0.86rem;
    font-weight: 500;
    color: #fff;
    background: var(--text-color);
    box-shadow: var(--shadow-md);
    animation: toastIn 0.18s ease;
    max-width: 280px;
}
.toast-success { background: var(--success-color); }
.toast-error   { background: var(--danger-color); }
.toast-out     { animation: toastOut 0.38s ease forwards; }

@keyframes toastIn  { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; } }
@keyframes toastOut { to { opacity: 0; } }

/* ============================================================================
   LOADING
   ============================================================================ */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}
.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}
@keyframes dots {
    0%,20%  { content: '.'; }
    40%     { content: '..'; }
    60%,100%{ content: '...'; }
}

/* ============================================================================
   FOOTER
   ============================================================================ */
.footer {
    background: #fff;
    padding: 1.6rem 0;
    text-align: center;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    font-size: 0.88rem;
}
.footer a { color: inherit; }

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 520px) {
    .header-inner    { flex-direction: column; align-items: flex-start; }
    .header-actions  { width: 100%; }
    .poll-card-top   { flex-wrap: wrap; gap: 0.6rem; }
    .poll-card-title { width: 100%; }
    .modal-footer    { flex-direction: column-reverse; }
}

/* ============================================================================
   PRINT / PDF
   ============================================================================ */
@media print {
    .no-print   { display: none !important; }
    .print-only { display: block !important; }

    body {
        background: white;
        padding-top: 0;
        font-size: 11pt;
        color: #000;
    }

    .main-content { padding: 0; }
    .container    { max-width: 100%; padding: 0; }

    /* Kort i print */
    .poll-card {
        border: 1pt solid #ccc;
        border-radius: 4pt;
        box-shadow: none;
        margin-bottom: 0.5cm;
        page-break-inside: avoid;
        overflow: visible;
    }

    .poll-card-top {
        padding: 0.3cm 0.5cm;
        border-bottom: 0.5pt solid #ccc;
        background: #f5f5f5 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .poll-card-title { font-size: 12pt; font-weight: 700; }

    .poll-card-description {
        font-size: 9pt;
        color: #555;
        margin-top: 0.1cm;
    }

    /* Vis print-tæller i stedet for +/- knapper */
    .counter-print {
        display: inline-block !important;
        font-size: 14pt;
        font-weight: 700;
        min-width: 2rem;
        text-align: right;
    }

    /* Deltager-sektion i print: skjul toggle-knap, vis altid indhold */
    .participants-toggle { display: none !important; }

    .participants-wrap {
        display: block !important;
        padding: 0.2cm 0.5cm 0.3cm;
        animation: none;
    }

    .participants-section {
        border-top: 0.5pt solid #ccc;
    }

    /* Skjul textarea, vis print-div */
    .participants-print {
        display: block !important;
        font-size: 10pt;
        color: #222;
        line-height: 1.6;
    }

    /* Tom deltager-sektion skjules i print */
    .participants-section:has(.participants-print:empty) {
        display: none;
    }

    .poll-card-actions { display: none !important; }

    @page {
        margin: 2cm;
        size: A4 portrait;
    }
}