@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* {
    box-sizing: border-box;
}

@keyframes pageLoad {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

:root {
    /* Light Theme (Default) */
    --primary: #990000;
    --primary-hover: #770000;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --success: #10b981;
    --pill-bg: #f1f5f9;
    --pill-hover: #e2e8f0;
    --th-bg: #f1f5f9;
    --hover-bg: #f8fafc;
    --input-bg: #ffffff;
}

:root[data-theme="dark"] {
    /* Dark Theme (Based on Sam reference) */
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --bg: #111827; /* Dark slate */
    --card-bg: #1f2937; /* Lighter slate for cards */
    --text: #f9fafb;
    --text-muted: #9ca3af;
    --border: #374151;
    --danger: #ef4444;
    --success: #10b981;
    --pill-bg: #374151;
    --pill-hover: #4b5563;
    --th-bg: #1f2937;
    --hover-bg: #111827;
    --input-bg: #111827;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary: #0ea5e9;
        --primary-hover: #0284c7;
        --bg: #111827;
        --card-bg: #1f2937;
        --text: #f9fafb;
        --text-muted: #9ca3af;
        --border: #374151;
        --danger: #ef4444;
        --success: #10b981;
        --pill-bg: #374151;
        --pill-hover: #4b5563;
        --th-bg: #1f2937;
        --hover-bg: #111827;
        --input-bg: #111827;
    }
}

html {
    overflow-y: scroll;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Site Header */
.site-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.header-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Site Footer */
.site-footer {
    background: var(--card-bg);
    color: var(--text);
    border-top: 1px solid var(--border);
    padding: 40px 0;
    margin-top: auto;
}

.footer-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

.footer-content p {
    margin: 0;
    font-size: 0.9rem;
}

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

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

.container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
    animation: pageLoad 0.4s ease-out forwards;
}

h1 {
    font-weight: 700;
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--text);
}

h2 {
    font-weight: 600;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

/* Dashboard Menu */
.menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.menu a {
    background: var(--card-bg);
    padding: 16px 24px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.menu a:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    color: var(--primary);
}

/* Nav Pills */
.nav-pills {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    margin-bottom: 24px;
    padding-bottom: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.nav-pills::-webkit-scrollbar {
    display: none;
}

.nav-pill {
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--pill-bg);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.nav-pill:hover {
    background: var(--pill-hover);
    color: var(--text);
    text-decoration: none !important;
}

.nav-pill.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

/* Theme Toggle */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--pill-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.theme-toggle:hover {
    background: var(--pill-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.theme-toggle .icon {
    font-size: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    border: none;
}

.btn-primary { background: var(--primary); color: white !important; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none !important; }

.btn-secondary { background: var(--card-bg); color: var(--text) !important; border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: var(--text-muted); text-decoration: none !important; }

.btn-danger { background: var(--card-bg); color: var(--danger) !important; border: 1px solid var(--border); }
.btn-danger:hover { background: #fef2f2; border-color: var(--danger); text-decoration: none !important; }

/* Tables */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: var(--th-bg);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    vertical-align: middle;
}

td {
    padding: 12px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    vertical-align: middle;
    word-break: break-word;
}

th:first-child, td:first-child {
    white-space: nowrap;
    width: 1%;
}

tr:hover td {
    background-color: var(--hover-bg);
}

tr.unpublished td {
    background-color: #fef2f2;
    color: #991b1b;
}

tr.unpublished:hover td {
    background-color: #fee2e2;
}

/* Forms */
form {
    background: var(--card-bg);
    padding: 32px;
    border-radius: 12px;
    border: 1px solid var(--border);
    max-width: 100%;
    margin: 0 auto;
}

.section-divider {
    margin: 40px 0 20px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-divider:first-child {
    margin-top: 0;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 8px;
    color: var(--text-muted);
}

input[type="text"], 
input[type="number"], 
select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text);
    background-color: var(--input-bg);
    transition: all 0.2s;
    outline: none;
}

textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text);
    background-color: var(--input-bg);
    transition: border-color 0.2s;
    outline: none;
    resize: none;
    overflow-y: hidden;
    min-height: 100px;
}

/* Custom Dropdown Styling */
select {
    width: 100%;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Hide custom arrow for listboxes */
select[size], 
select[multiple] {
    background-image: none;
    padding-right: 12px;
}

input:focus, 
select:focus, 
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Multi-select / Listbox styling */
select[size], 
select[multiple] {
    padding: 4px;
    height: auto;
}

select[size] option, 
select[multiple] option {
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 2px;
}

select[size] option:checked, 
select[multiple] option:checked {
    background-color: var(--primary) !important;
    color: white !important;
}

/* Project View */
.section {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.label-meta {
    font-weight: 600;
    color: var(--text-muted);
    width: 180px;
    display: inline-block;
}

.lang-switch {
    margin-bottom: 24px;
    display: flex;
    gap: 8px;
}

.lang-content { display: none; }
.lang-content.active { display: block; }

.btn-info { background: #ecfdf5; color: var(--success); border: 1px solid #d1fae5; }
.btn-info:hover { background: #d1fae5; }

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .header-left a {
        justify-content: center;
    }

    .container {
        margin: 20px auto;
    }

    /* Wrap filter dropdowns on mobile */
    .filter-row {
        flex-wrap: wrap;
    }
    .filter-row > select {
        flex: 1 1 45%;
        min-width: 120px;
    }

    /* Stack grid layout vertically */
    .grid {
        grid-template-columns: 1fr !important;
    }

    /* Make nav pills wrap on mobile */
    .nav-pills {
        flex-wrap: wrap;
        padding-bottom: 0;
    }
    
    .nav-pill {
        flex: 1 1 calc(50% - 6px);
        text-align: center;
        padding: 8px 10px;
    }

    /* Prevent tables from squashing columns on mobile, but don't make them infinitely wide */
    table {
        min-width: 100%;
    }

    th {
        white-space: nowrap;
    }
    
    td {
        white-space: normal;
        min-width: 120px;
    }

    /* Actions column should never wrap */
    td:last-child {
        white-space: nowrap;
    }

    h1 {
        font-size: 1.5rem;
    }

    .hide-mobile {
        display: none !important;
    }
}
