:root {
    --bg-color: #000000;
    --surface-color: #121212;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent: #3b82f6;
    /* Flat Solid Blue */
    --accent-hover: #2563eb;
    --success: #10b981;
    /* Flat Solid Green */
    --border-color: #27272a;
    --radius: 16px;
    --btn-radius: 8px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 3rem 1rem;
    min-height: 100vh;
}

/* Top Actions Bar */
.top-actions {
    position: absolute;
    top: 2rem;
    right: 2rem;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Language Switcher */
/* Remove empty rule or use it for specific layout adjustments if needed later */

#lang-select {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.2rem;
    border-radius: var(--btn-radius);
    outline: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
}

#lang-select:hover {
    background-color: #1e1e1e;
}

/* Author Footer Link */
.author-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
    font-weight: 500;
}

.author-link:hover {
    color: var(--accent);
}

.author-logo {
    height: 24px;
    width: auto;
    /* Prevent stretching */
    display: block;
    object-fit: contain;
}

.container {
    max-width: 1200px;
    /* More focused width for list */
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 4rem;
}

.site-logo {
    display: block;
    margin: 0 auto 2rem auto;
    max-height: 120px;
    width: auto;
    /* No filters, No shadows */
}

header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.progress-container {
    margin-top: 2rem;
    background: var(--surface-color);
    height: 6px;
    border-radius: 99px;
    overflow: hidden;
    position: relative;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    /* Solid flat color */
    width: 0%;
    transition: width 0.3s ease;
    text-align: right;
    line-height: 6px;
    color: transparent;
    /* Hid text inside thin bar */
}

#checklist-app {
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.category {
    /* OLED minimal: No background cards, just groupings */
    padding: 0;
    background: transparent;
    border: none;
}

.category h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-primary);
    border-left: 4px solid var(--accent);
    padding-left: 1rem;
    line-height: 1.2;
}

/* Critical Category Styling */
.category.critical h2 {
    border-left-color: #ef4444;
    /* Red accent for critical */
}

.category.critical h2 i {
    color: #ef4444;
}

.badge {
    font-size: 0.75rem;
    background: #ef4444;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    margin-left: auto;
    text-transform: uppercase;
}

.checklist {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    /* Grid layout for items */
    gap: 1rem;
}

.checklist li {
    background: var(--surface-color);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

.checklist li:hover {
    background: #1a1a1a;
}

.checklist label {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    gap: 0.75rem;
    align-items: center;
    /* Center vertically in row */
    cursor: pointer;
    padding: 1.5rem;
    height: 100%;
    width: 100%;
    text-align: left;
}

.item-icon {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 48px;
    height: 48px;
    object-fit: contain;
    margin: 0 auto 1rem auto;
    /* Horizontally centered in grid cell */
    display: block;
}

.checklist input[type="checkbox"] {
    display: none;
}

/* Custom Flat Checkbox - placed in row 2, col 1 */
.check-box {
    grid-row: 2;
    grid-column: 1;
    width: 24px;
    height: 24px;
    border: 2px solid #525252;
    border-radius: 6px;
    position: relative;
    background: transparent;
    transition: all 0.2s ease;
    margin-right: 0.5rem;
    /* Gap between box and text */
}

/* RTL adjustment for margin */
[dir="rtl"] .check-box {
    margin-right: 0;
    margin-left: 0.5rem;
}

.checklist input[type="checkbox"]:checked+.check-box {
    background: var(--success);
    border-color: var(--success);
}

/* Checkmark using CSS shapes for cleaner flat look */
.check-box::after {
    content: '';
    position: absolute;
    left: 7px;
    top: 3px;
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.checklist input[type="checkbox"]:checked+.check-box::after {
    transform: rotate(45deg) scale(1);
}

/* Text - placed in row 2, col 2 */
.text {
    grid-row: 2;
    grid-column: 2;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.text strong,
.text small {
    /* Ensure long words break instead of overflowing */
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
}

.text strong {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 1rem;
}

.text small {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Checked state styling */
.checklist input[type="checkbox"]:checked~.text strong {
    color: var(--text-secondary);
    /* Just dim the color, no strikethrough */
}

.checklist input[type="checkbox"]:checked~.text small {
    color: var(--text-secondary);
}

footer {
    text-align: center;
    margin-top: 5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

#reset-btn {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.8rem 1.5rem;
    border-radius: var(--btn-radius);
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#reset-btn:hover {
    background: #1e1e1e;
    border-color: #ef4444;
    color: #ef4444;
}

footer p {
    color: #404040;
    font-size: 0.9rem;
}

/* 
   Arabic / Darija Fonts & Direction 
   We handle text direction via CSS class helpers from script logic, 
   but specific font application is here.
*/
[lang="ar"] body,
[lang="ma"] body {
    font-family: 'Cairo', sans-serif;
}

/* Text alignment overrides for Arabic */
[lang="ar"] .text,
[lang="ma"] .text {
    direction: rtl;
}

[lang="ar"] .category h2,
[lang="ma"] .category h2 {
    direction: rtl;
    border-left: none;
    border-right: 4px solid var(--accent);
    /* Flip border */
    padding-left: 0;
    padding-right: 1rem;
}

[lang="ar"] .category.critical h2,
[lang="ma"] .category.critical h2 {
    border-right-color: #ef4444;
}

[lang="ar"] .badge,
[lang="ma"] .badge {
    margin-left: 0;
    margin-right: auto;
}

@media (max-width: 600px) {
    header h1 {
        font-size: 1.8rem;
    }

    .checklist {
        grid-template-columns: 1fr;
        /* Single column on mobile */
    }

    .top-actions {
        position: static;
        margin-bottom: 2rem;
        flex-direction: column;
        gap: 1rem;
        width: 100%;
        align-items: center;
    }

    .lang-switcher {
        width: 100%;
        text-align: center;
    }

    #lang-select {
        width: 100%;
        max-width: 200px;
        text-align: center;
    }
}

/* How Button */
.how-btn {
    grid-row: 2;
    grid-column: 2;
    /* Same column as text, but we need to float or flex it */
    justify-self: end;
    /* Align to right */
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--accent);
    padding: 0.25rem 0.75rem;
    border-radius: var(--btn-radius);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s;
    margin-top: auto;
    /* Push to bottom if height varies */
    margin-bottom: auto;
}

[dir="rtl"] .how-btn {
    justify-self: end;
    /* In RTL grid, end is left? No, end is right in LTR, left in RTL? 
                         Actually grid tracks follow direction. 
                         Col 1 is right, Col 2 is left in RTL grid?
                         Let's verify. 
                         grid-template-columns: auto 1fr;
                         In LTR: Col1 (auto) [check], Col2 (1fr) [text].
                         In RTL: Col1 (auto) [check], Col2 (1fr) [text].
                         So justify-self: end on col 2 puts it far away from checkbox.
                         Wait, text is also in col 2.
                         Ideally we want button on the far edge.
                         Let's make a 3rd column? Or absolute position.
                      */
}

.how-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Coffee Button */
.coffee-btn {
    background-color: #FFDD00;
    color: #000;
    padding: 0.6rem 1.2rem;
    border-radius: var(--btn-radius);
    text-decoration: none;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 0.95rem;
}

.coffee-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 221, 0, 0.3);
}

/* Update grid to accommodate button without overlapping text */
.checklist label {
    grid-template-columns: auto 1fr auto;
    /* Checkbox, Text, Button */
    padding: 1.5rem 1rem;
    /* slightly less horizontal padding to gain space */
    column-gap: 1rem;
    /* Increase gap between columns */
    position: relative;
    /* For absolute positioning if needed, but grid should work */
}

/* Update text column span */
.text {
    grid-column: 2;
    padding-right: 0.5rem;
    /* Extra buffer */
}

/* Update button position in grid */
.how-btn {
    grid-column: 3;
    grid-row: 2;
    white-space: nowrap;
    /* Prevent button text wrapping */
    min-width: fit-content;
}

/* Side Panel */
.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: #0a0a0a;
    border-left: 1px solid var(--border-color);
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    padding: 2rem;
}

.side-panel.open {
    transform: translateX(0);
}

/* RTL Side Panel */
[dir="rtl"] .side-panel {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid var(--border-color);
    transform: translateX(-100%);
}

[dir="rtl"] .side-panel.open {
    transform: translateX(0);
}

.close-btn {
    align-self: flex-end;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.5rem;
}

[dir="rtl"] .close-btn {
    align-self: flex-start;
}

.panel-content {
    margin-top: 1rem;
    overflow-y: auto;
}

.panel-content h2 {
    color: var(--accent);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.panel-body {
    color: var(--text-primary);
    line-height: 1.6;
}

.panel-image-placeholder {
    width: 100%;
    aspect-ratio: 16/9;
    background: #1a1a1a;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2rem;
    overflow: hidden;
}

.placeholder-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#panel-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(2px);
}

.overlay.active {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 600px) {
    .side-panel {
        width: 100%;
    }
}
