/* ==========================================
   1. MASTER VARIABLES (Unified Theme)
========================================== */
:root {
    --bg-void: #0b0f19;
    --bg-panel: #0f172a;
    --card-bg: #1e293b;
    --border-color: #334155;
    
    --accent-cyan: #00f2fe;
    --accent-gold: #fbbf24;
    --danger: #ef4444;
    --success: #22c55e;
    --elite-purple: #c38dff;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
}

/* ==========================================
   2. BASE & RESET
========================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-void);
    color: var(--text-main);
    min-height: 100vh;
    padding-bottom: 140px; 
}

/* ==========================================
   3. NAVIGATION & LAYOUT
========================================== */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: 1px;
}

.logo span { color: var(--accent-cyan); }
.stats { font-size: 0.9rem; color: var(--accent-cyan); font-weight: 600; }

.dashboard {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* ==========================================
   4. CONTROL PANEL & FILTERS
========================================== */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    background-color: rgba(30, 41, 59, 0.5);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.filter-input, .filter-dropdown {
    background-color: var(--bg-void);
    color: var(--text-main);
    border: 1px solid #475569;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    outline: none;
    font-size: 0.9rem;
    flex: 1;
    min-width: 200px;
    transition: border-color 0.2s;
}

.filter-input:focus, .filter-dropdown:focus { border-color: var(--accent-cyan); }

/* ==========================================
   5. FLEET GRID & SHIP CARDS
========================================== */
.fleet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1.5rem;
}

.ship-card {
    background-color: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 0.5rem;
    position: relative;
}

.ship-icon {
    width: 100%;
    aspect-ratio: 1 / 1; 
    object-fit: cover;
    background-color: var(--bg-panel);
    border-bottom: 2px solid var(--border-color);
}

.ship-name {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    text-align: center;
    padding: 0 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* ==========================================
   6. GLOBAL RARITY SYSTEM
========================================== */
.rarity-label {
    position: absolute; top: 5px; right: 5px; font-size: 0.65rem; font-weight: 800;
    padding: 2px 6px; border-radius: 4px; background: rgba(15, 23, 42, 0.85);
    text-transform: uppercase; letter-spacing: 0.5px; z-index: 10; backdrop-filter: blur(2px);
}

.rarity-common .ship-icon { border-bottom: 3px solid var(--text-muted); }
.rarity-common .rarity-label { color: var(--text-muted); border: 1px solid var(--text-muted); }
.rarity-common:hover { border-color: var(--text-muted); box-shadow: 0 4px 12px rgba(148, 163, 184, 0.2); }

.rarity-rare .ship-icon { border-bottom: 3px solid #3b82f6; }
.rarity-rare .rarity-label { color: #3b82f6; border: 1px solid #3b82f6; }
.rarity-rare:hover { border-color: #3b82f6; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2); }

.rarity-elite .ship-icon { border-bottom: 3px solid var(--elite-purple); }
.rarity-elite .rarity-label { color: var(--elite-purple); border: 1px solid var(--elite-purple); }
.rarity-elite:hover { border-color: var(--elite-purple); box-shadow: 0 4px 12px rgba(195, 141, 255, 0.3); }

.rarity-ssr .ship-icon { border-bottom: 3px solid var(--accent-gold); }
.rarity-ssr .rarity-label { color: var(--accent-gold); border: 1px solid var(--accent-gold); }
.rarity-ssr:hover { border-color: var(--accent-gold); box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3); }

.rarity-ur .ship-icon { border-bottom: 3px solid var(--danger); } 
.rarity-ur .rarity-label {
    background: linear-gradient(90deg, #f43f5e, #fbbf24, #3b82f6);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    border: 1px solid var(--danger);
}
.rarity-ur:hover { border-color: var(--danger); box-shadow: 0 4px 15px rgba(244, 63, 94, 0.4); }

/* ==========================================
   7. MODAL SYSTEM (Dossier & Roster)
========================================== */
.modal-backdrop {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: rgba(11, 15, 25, 0.85); backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center; z-index: 1000;
    opacity: 1; visibility: visible; transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal-backdrop.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.modal-content {
    background-color: var(--card-bg); width: 90%; max-width: 1100px; height: 80vh;
    border-radius: 12px; 
    border: 1px solid var(--modal-accent, var(--accent-cyan));
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 35px var(--modal-glow, transparent); 
    position: relative; overflow: hidden;
    display: flex; flex-direction: column;
}

.close-btn {
    position: absolute; top: 15px; right: 20px; background: none; border: none;
    color: var(--text-muted); font-size: 2rem; cursor: pointer; z-index: 10; transition: color 0.2s;
}
.close-btn:hover { color: var(--danger); }

/* ==========================================
   8. DOSSIER SPECIFICS
========================================== */
.dossier-layout { display: flex; height: 100%; }
.dossier-art-container {
    flex: 1.5; background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    display: flex; justify-content: center; align-items: center; overflow: hidden; position: relative;
}
.dossier-art {
    width: 100%; height: 100%; object-fit: contain;
    filter: drop-shadow(0 0 15px rgba(34, 211, 238, 0.2));
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.scale-normal { transform: scale(1.05); }
.scale-large { transform: scale(1.20); }
.scale-massive { transform: scale(1.75); }
.scale-normal:hover { transform: scale(1.20); cursor: zoom-in; }
.scale-large:hover { transform: scale(1.45); cursor: zoom-in; }
.scale-massive:hover { transform: scale(2.00); cursor: zoom-in; }

.dossier-intel { flex: 1; padding: 3rem 2rem; display: flex; flex-direction: column; }
.dossier-title { font-size: 2.5rem; color: var(--modal-accent, var(--accent-cyan)); margin-bottom: 1rem; }
.dossier-tags { display: flex; gap: 1rem; margin-bottom: 2rem; }

/* Dynamic Tags */
.tag { padding: 0.4rem 1rem; border-radius: 20px; font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.faction-tag, .type-tag {
    background-color: rgba(15, 23, 42, 0.6) !important;
    color: var(--modal-accent, var(--accent-cyan)) !important;
    border: 1px solid var(--modal-accent, var(--accent-cyan)) !important;
}

/* Stats & Skills */
.dossier-stats-container h3 { color: var(--accent-cyan); font-size: 14px; margin-bottom: 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); padding-bottom: 5px; text-transform: uppercase; }
.dossier-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.stat-box { background: rgba(15, 23, 42, 0.6); border: 1px solid var(--border-color); border-radius: 6px; padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; }
.stat-name { color: var(--text-muted); font-weight: bold; font-size: 11px; flex-grow: 1; margin-left: 6px; }
.stat-val { color: #fff; font-weight: bold; font-family: monospace; font-size: 14px; }

.stats-header-row { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255, 255, 255, 0.1); margin-bottom: 15px; padding-bottom: 5px; }
.stats-header-row h3 { border: none; margin: 0; padding: 0; }
.stat-tabs { display: flex; gap: 4px; }
.stat-tab { background: rgba(15, 23, 42, 0.6); border: 1px solid var(--border-color); color: var(--text-muted); font-size: 10px; padding: 4px 8px; border-radius: 4px; cursor: pointer; font-weight: bold; transition: all 0.2s; }
.stat-tab:hover { border-color: var(--modal-accent, var(--accent-cyan)); color: #fff; }
.stat-tab.active { background: var(--modal-accent, var(--accent-cyan)); color: #000; border-color: var(--modal-accent, var(--accent-cyan)); }

.skills-container { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-height: 240px; overflow-y: auto; padding-right: 5px; padding-bottom: 15px; }
.skills-container::-webkit-scrollbar { width: 4px; }
.skills-container::-webkit-scrollbar-thumb { background: var(--accent-cyan); border-radius: 4px; }
.skill-item { display: flex; gap: 12px; background: rgba(0, 0, 0, 0.3); padding: 10px; border-radius: 6px; border-left: 3px solid var(--modal-accent, var(--accent-cyan)); border-top: 1px solid rgba(255, 255, 255, 0.05); border-right: 1px solid rgba(255, 255, 255, 0.05); border-bottom: 1px solid rgba(255, 255, 255, 0.05); align-items: flex-start; }
.skill-item:last-child { margin-bottom: 10px; }
.skill-icon { width: 48px; height: 48px; border-radius: 6px; flex-shrink: 0; border: 1px solid var(--border-color); }
.skill-info { display: flex; flex-direction: column; gap: 4px; }
.skill-name { color: var(--modal-accent, var(--accent-cyan)); font-weight: bold; font-size: 13px; text-transform: uppercase; }
.skill-desc { color: #cbd5e1; font-size: 11px; line-height: 1.4; }
.awaiting-data { color: var(--text-muted); font-size: 11px; font-style: italic; }

/* Wardrobe Navigation */
.skin-nav-btn { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(15, 23, 42, 0.6); color: var(--modal-accent, var(--accent-cyan)); border: 1px solid var(--modal-accent, var(--accent-cyan)); border-radius: 50%; width: 45px; height: 45px; font-size: 1.2rem; cursor: pointer; z-index: 30; transition: all 0.2s ease; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(4px); }
.skin-nav-btn:hover { background: var(--modal-accent, var(--accent-cyan)); color: #0f172a; box-shadow: 0 0 15px var(--modal-glow, rgba(34, 211, 238, 0.5)); transform: translateY(-50%) scale(1.1); }
.skin-prev { left: 15px; }
.skin-next { right: 15px; }
.skin-name-label { position: absolute; bottom: 25px; left: 50%; transform: translateX(-50%); background: rgba(15, 23, 42, 0.85); border: 1px solid var(--border-color); color: var(--text-main); padding: 6px 20px; border-radius: 20px; font-size: 0.85rem; font-weight: bold; z-index: 30; letter-spacing: 1px; box-shadow: 0 4px 10px rgba(0,0,0,0.5); backdrop-filter: blur(4px); text-transform: uppercase; pointer-events: none; }

/* ==========================================
   9. THE TOGGLE SWITCHES
========================================== */
.dossier-header { position: absolute; top: 15px; left: 20px; z-index: 20; }
.theme-switch { display: inline-block; position: relative; width: 200px; height: 34px; cursor: pointer; }
.global-switch { margin-right: auto; box-shadow: 0 0 10px rgba(0,0,0,0.5); }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--bg-void); border: 1px solid var(--accent-cyan); border-radius: 34px; transition: .4s; display: flex; align-items: center; justify-content: space-between; padding: 0 15px; }
.slider::before { position: absolute; content: ""; height: 26px; width: 90px; left: 3px; bottom: 3px; background-color: rgba(34, 211, 238, 0.2); border-radius: 34px; transition: .4s; }
input:checked + .slider::before { transform: translateX(100px); background-color: rgba(212, 163, 115, 0.3); }
input:checked + .slider { border-color: #d4a373; }
.slider-text { font-size: 0.75rem; font-weight: bold; text-transform: uppercase; z-index: 1; transition: color 0.3s; }
.game-text { color: var(--accent-cyan); }
.history-text { color: #475569; }
input:checked + .slider .game-text { color: #475569; }
input:checked + .slider .history-text { color: #d4a373; }

/* ==========================================
   10. HISTORICAL ARCHIVE THEME
========================================== */
.dossier-body { height: 100%; position: relative; }
.view-game, .view-history { position: absolute; top: 0; left: 0; right: 0; bottom: 0; opacity: 0; pointer-events: none; transition: opacity 0.5s ease; }
.active-view { opacity: 1; pointer-events: all; }

.modal-content.is-historical { border-color: #d4a373; box-shadow: 0 10px 30px rgba(212, 163, 115, 0.2); }
.photo-texture { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: url('https://www.transparenttextures.com/patterns/dust.png'); opacity: 0.6; pointer-events: none; }
.history-title { font-size: 2.5rem; border-bottom: 2px dashed #a89f91; padding-bottom: 10px; margin-bottom: 20px; }
.history-specs { list-style: none; margin-bottom: 30px; line-height: 1.8; }
.history-logs h3 { margin-bottom: 15px; text-decoration: underline; }

.view-history { flex-direction: column; background-color: #e8dcc4; background-image: url('https://www.transparenttextures.com/patterns/aged-paper.png'); color: #2c2a25; font-family: 'Courier New', Courier, monospace; }
.history-art-container { flex: none; height: 55%; width: 100%; border-bottom: 3px solid #8b2626; position: relative; overflow: hidden; }
.history-photo { width: 100%; height: 100%; object-fit: cover; object-position: center; filter: sepia(0.6) grayscale(0.8) contrast(1.2) opacity(0.9); }
.history-intel { flex: none; height: 45%; padding: 2rem 3rem; overflow-y: auto; position: relative; }
.classified-stamp { position: absolute; top: 15px; right: 30px; color: #c0392b; border: 3px solid #c0392b; padding: 5px 15px; font-size: 1.5rem; font-weight: bold; transform: rotate(15deg); opacity: 0.6; letter-spacing: 2px; pointer-events: none; }

body.historical-theme { --bg-void: #d5c7a3; --card-bg: #e8dcc4; --text-main: #2c2a25; --text-muted: #5c5549; --accent-cyan: #8b2626; background-image: url('https://www.transparenttextures.com/patterns/aged-paper.png'); font-family: 'Courier New', Courier, monospace; }
body.historical-theme .top-nav { background-color: rgba(213, 199, 163, 0.95); border-bottom: 2px solid #8b2626; }
body.historical-theme .filter-input, body.historical-theme .filter-dropdown { border-color: #a89f91; font-weight: bold; }
body.historical-theme .ship-card { border: 1px solid #a89f91; border-radius: 2px; box-shadow: 2px 2px 5px rgba(0,0,0,0.1); }
body.historical-theme .ship-icon { filter: sepia(0.7) grayscale(0.6) contrast(1.1); border-bottom: 1px solid #a89f91; }
body.historical-theme .ship-name { font-weight: bold; text-transform: uppercase; letter-spacing: 1px; }

/* ==========================================
   11. DYNAMIC DOSSIER RARITY COLORING
   ========================================== */
.dossier-ur     { --modal-accent: #f43f5e; --modal-glow: rgba(244, 63, 94, 0.15); }
.dossier-ssr    { --modal-accent: #fbbf24; --modal-glow: rgba(251, 191, 36, 0.15); }
.dossier-elite  { --modal-accent: #c38dff; --modal-glow: rgba(195, 141, 255, 0.15); }
.dossier-rare   { --modal-accent: #4fc3f7; --modal-glow: rgba(79, 195, 247, 0.15); }
.dossier-common { --modal-accent: #94a3b8; --modal-glow: rgba(148, 163, 184, 0.15); }

#dossier-rarity-badge {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: var(--modal-accent, var(--accent-cyan));
    color: #0b0f19;
    padding: 5px 15px;
    font-weight: 900;
    border-radius: 4px;
    letter-spacing: 1px;
    box-shadow: 0 0 10px var(--modal-glow, rgba(0, 242, 254, 0.5));
    z-index: 10;
}