:root {
    --primary: #007bff;
    --primary-hover: #0056b3;
    --bg-light: #f4f4f4;
    --bg-dark: #393939;
    --card-light: #ffffff;
    --card-dark: #1e1e1e;
    --text-light: #333;
    --text-dark: #fff;
    --danger: #dc3545;
    --success: #28a745;
}

* {
    box-sizing: border-box; 
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-light);
    color: var(--text-light);
    overflow-x: hidden;
}

/* --- Brand Header Styles --- */
.brand-header-strip {
    width: 100%;
    /* Fallback color ensures text is visible if gradient fails */
    background-color: #05152e; 
    /* The Gradient */
    background: linear-gradient(90deg, #05152e 0%, #1e4b8f 50%, #05152e 100%);
    border-bottom: 1px solid #004a99;
    padding: 15px 0;
    text-align: center;
}

.brand-link-wrapper {
    text-decoration: none;
    display: inline-block;
    color: white;
}

.brand-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px; 
}

.brand-logo {
    height: 50px; 
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.brand-text {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.brand-title {
    font-family: 'Georgia', serif; 
    font-size: 32px;
    font-weight: bold;
    line-height: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.brand-subtitle {
    font-family: 'Segoe UI', sans-serif;
    font-size: 16px;
    opacity: 0.95;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

@media (max-width: 600px) {
    .brand-content { flex-direction: column; gap: 5px; }
    .brand-text { text-align: center; }
    .brand-title { font-size: 24px; }
    .brand-subtitle { font-size: 14px; }
}

/* --- Layout Grid --- */
.main-layout {
    display: flex;
    flex-direction: column;
    padding: 15px;
    gap: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

@media (min-width: 1025px) {
    .main-layout {
        flex-direction: row;
        align-items: flex-start;
    }
    .content-column { flex: 3; }
    .sidebar-column {
        flex: 1;
        position: sticky;
        top: 20px;
        min-width: 350px;
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* --- Header & Buttons --- */
.title-card {
    background: var(--primary);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

button {
    padding: 10px 15px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}
button:hover { background-color: var(--primary-hover); }
button:disabled { background-color: #ccc; cursor: not-allowed; }

.action-btn { width: 100%; margin-bottom: 8px; }
.action-btn.success { background-color: var(--success); }
.action-btn.danger { background-color: var(--danger); }
.action-btn.secondary { background-color: #6c757d; }

#searchInput {
    width: 100%;
    max-width: 400px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

/* --- Mod Grid --- */
.mod-list {
    display: grid;
    grid-template-columns: 1fr; 
    gap: 20px;
    margin-bottom: 40px;
}

@media (min-width: 600px) { .mod-list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .mod-list { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1600px) { .mod-list { grid-template-columns: repeat(4, 1fr); } }

.mod-list > div { height: 100%; }

.mod-card {
    background: var(--card-light);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.2s;
}
.mod-card:hover { transform: translateY(-3px); }

.mod-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 5px;
    margin-bottom: 15px;
}

.mod-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.mod-info h3 {
    font-size: 18px;
    margin: 0 0 10px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mod-info p { 
    font-size: 14px; 
    color: #666; 
    margin: 0 0 8px 0; 
}

.mod-info button, .mod-info a {
    margin-top: 10px;
    width: 100%;
    text-decoration: none;
    text-align: center;
    display: block; 
}

.mod-info a {
    background-color: #6c757d;
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 13.33px; 
}
.mod-info a:hover { background-color: #5a6268; }

/* --- Sidebar --- */
.currentList {
    background-color: var(--card-light);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.sidebar-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.sidebar-header-row h2 { margin: 0; font-size: 1.2rem; }

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    background: transparent;
    border: 1px solid #ccc;
    color: #555;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}
.icon-btn:hover { background: #eee; color: #000; }

.total-size-badge {
    background-color: #e9ecef;
    color: #495057;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
}

.sidebar-search {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* --- Selected Items --- */
.selected-mods-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
    min-height: 50px;
}

.selected-mod-item {
    display: flex;
    flex-direction: column; 
    background: #f8f9fa;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #eee;
    cursor: grab;
}
.selected-mod-item:active { cursor: grabbing; }

.selected-mod-row {
    display: flex;
    align-items: center;
    width: 100%;
}

.selected-mod-thumb {
    width: 45px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 12px;
    flex-shrink: 0;
}

.selected-mod-details { flex-grow: 1; overflow: hidden; min-width: 0; }

.selected-mod-name {
    font-weight: bold;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meta-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 4px;
}

.badge {
    font-size: 11px;
    padding: 3px 6px;
    border-radius: 3px;
    background: #e9ecef;
    color: #666;
}
.badge-size { background: #d1ecf1; color: #0c5460; }
.badge-deps { background: #fff3cd; color: #856404; cursor: pointer; }

.version-select {
    background: transparent;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 2px;
    font-size: 11px;
    color: #555;
    max-width: 100%;
    margin-top: 2px;
}

.remove-btn {
    background: none;
    color: #dc3545;
    padding: 8px;
    font-size: 20px;
    margin-left: 5px;
}

/* Dependencies List */
.dependency-list {
    width: 100%;
    margin-top: 8px;
    background: #fff;
    border-top: 1px solid #eee;
    padding: 8px 5px;
    font-size: 12px;
    display: none;
}
.dependency-list.active { display: block; animation: fadeIn 0.3s; }
.dep-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px dashed #eee;
    color: #555;
}

/* --- FULL SCREEN SIDEBAR MODE --- */
.currentList.fullscreen-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; 
    z-index: 99999;
    margin: 0;
    border-radius: 0;
    padding: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: none;
    background-color: var(--card-light);
}

@media (min-width: 768px) {
    .currentList.fullscreen-mode {
        top: 5%;
        left: 5%;
        width: 90%;
        height: 90%;
        border-radius: 8px;
        padding: 30px;
        box-shadow: 0 20px 50px rgba(0,0,0,0.5);
        outline: 100vmax solid rgba(0,0,0,0.6); 
    }
}

.currentList.fullscreen-mode .selected-mods-container {
    flex-grow: 1;
    overflow-y: auto;
    max-height: none;
    border: 1px solid #eee;
    padding: 15px;
    background: #fafafa;
}

.currentList.fullscreen-mode .import-area { display: none; }

/* --- TOAST NOTIFICATIONS --- */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100000;
}
.toast {
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    margin-top: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: slideIn 0.3s, fadeOut 0.3s 2.7s forwards;
    display: flex;
    align-items: center;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* --- SCENARIO OVERLAY --- */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100000;
    display: flex; 
    justify-content: center;
    align-items: center;
    transition: visibility 0s, opacity 0.2s linear;
}

.overlay.hidden {
    display: none !important;
    visibility: hidden;
    opacity: 0;
}

.overlay-content {
    background: white;
    color: black;
    max-width: 90%;
    width: 500px;
    padding: 20px;
    border-radius: 10px;
    overflow-y: auto;
    max-height: 80vh; 
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.overlay-content h2 {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    cursor: pointer;
    font-size: 1.5em;
    font-weight: bold;
    color: #555;
    transition: color 0.2s;
}
.close-btn:hover { color: red; }

/* --- PDF EXPORT STYLES --- */
#exportContainer { position: fixed; top: -20000px; left: -20000px; }

.export-canvas {
    width: 850px; 
    min-height: 1100px; 
    background-color: #ffffff;
    padding: 60px; 
    box-sizing: border-box;
    font-family: 'Georgia', 'Times New Roman', serif; 
    color: #222;
    border: 1px solid #eee; 
}

.export-header {
    text-align: center;
    border-bottom: 3px double #444;
    padding-bottom: 30px;
    margin-bottom: 40px;
}

.export-header h1 {
    margin: 0;
    font-size: 32px;
    color: #111;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.export-header p {
    margin: 10px 0 0 0;
    color: #666;
    font-style: italic;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.export-summary {
    display: flex;
    justify-content: space-between;
    background: #f4f4f4;
    padding: 20px 30px;
    border-radius: 4px;
    margin-bottom: 40px;
    font-family: 'Segoe UI', Arial, sans-serif;
    border-left: 5px solid #333;
}

.export-summary-item strong {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    color: #666;
}

.export-summary-item span {
    font-size: 24px;
    font-weight: bold;
    color: #111;
}

.export-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 40px;
}

.export-table th {
    text-align: left;
    border-bottom: 2px solid #333;
    padding: 12px 5px;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 12px;
    font-family: 'Segoe UI', Arial, sans-serif;
}

.export-table td {
    padding: 15px 5px;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: top;
}

.mod-name-cell { font-weight: bold; font-size: 15px; }

.export-dep-row td {
    background-color: #fafafa;
    color: #555;
    padding: 8px 5px 15px 25px; 
    font-size: 12px;
    font-family: 'Segoe UI', Arial, sans-serif;
    border-bottom: 1px solid #eee;
    font-style: italic;
}

.export-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    font-family: 'Segoe UI', Arial, sans-serif;
    text-transform: uppercase;
}
.badge-blue { background: #e6f0ff; color: #0056b3; border: 1px solid #b3d7ff; }
.badge-gray { background: #f0f0f0; color: #444; border: 1px solid #ddd; }

.export-footer {
    text-align: center;
    margin-top: 60px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    font-size: 11px;
    color: #888;
    font-family: 'Segoe UI', Arial, sans-serif;
}

/* --- Dark Mode --- */
body.dark-mode { background-color: var(--bg-dark); color: var(--text-dark); }
body.dark-mode .currentList, body.dark-mode .mod-card { background: var(--card-dark); color: var(--text-dark); }
body.dark-mode .selected-mod-item { background: #2a2a2a; border-color: #444; }
body.dark-mode .sidebar-header-row { border-bottom-color: #444; }
body.dark-mode .icon-btn { border-color: #555; color: #ccc; }
body.dark-mode .sidebar-search, body.dark-mode .version-select { background: #2a2a2a; border-color: #555; color: white; }
body.dark-mode .version-select option { background: #2a2a2a; }
body.dark-mode .total-size-badge { background: #444; color: #ddd; }
body.dark-mode .badge { background: #444; color: #bbb; }
body.dark-mode .dependency-list { background: #2a2a2a; border-top-color: #444; }
body.dark-mode .dep-item { border-bottom-color: #444; color: #aaa; }
body.dark-mode .currentList.fullscreen-mode { background-color: var(--card-dark); }
body.dark-mode .currentList.fullscreen-mode .selected-mods-container { background: #2a2a2a; border-color: #444; }
/* Overlays in Dark Mode */
body.dark-mode .overlay-content { background: #2a2a2a; color: #fff; }
body.dark-mode .overlay-content h2 { border-bottom-color: #444; }
body.dark-mode .close-btn { color: #aaa; }
body.dark-mode .close-btn:hover { color: #ff6b6b; }