/* --- 1. GLOBAL VARIABLES & THEME --- */
:root {
    --bg-dark: #0a0e14;       /* Deep Navy/Black */
    --panel-bg: rgba(20, 30, 40, 0.7); /* See-through glass */
    --cyan: #00f0ff;          /* The HUD Blue */
    --orange: #ff5500;        /* Alert/Action color */
    --success: #00ff41;       /* Green */
    --text-white: #e6f5ff;
    --grid-line: rgba(0, 240, 255, 0.05);
}

body {
    background-color: var(--bg-dark);
    background-image: 
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 40px 40px;
    color: var(--text-white);
    font-family: 'Rajdhani', sans-serif;
    margin: 0;
    padding-bottom: 90px; /* Space for bottom nav */
}

/* --- 2. HEADER --- */
header {
    background: linear-gradient(90deg, rgba(0,0,0,0.9), rgba(0,0,0,0));
    padding: 20px;
    border-bottom: 1px solid var(--cyan);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.1);
}

.brand { 
    font-size: 1.5em; 
    font-weight: 700; 
    letter-spacing: 3px;
    text-shadow: 0 0 5px var(--cyan);
}

.status-indicator { 
    font-weight: bold; 
    color: #ff3333; 
    font-size: 0.9em;
    background: rgba(50,0,0,0.5);
    padding: 2px 8px;
    border: 1px solid #ff3333;
}

/* --- 3. CARDS & LAYOUT --- */
.tab-content { padding: 20px; display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease-in-out; }

.card {
    background: var(--panel-bg);
    backdrop-filter: blur(5px);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(0, 240, 255, 0.2);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%);
    position: relative;
}

.card::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--cyan);
}

h2 { 
    color: var(--cyan); text-transform: uppercase; 
    border-bottom: 1px solid var(--cyan);
    display: inline-block; padding-right: 20px; margin-top: 0;
}

/* --- 4. BUTTONS --- */
button {
    background: rgba(0, 240, 255, 0.1);
    color: var(--cyan);
    border: 1px solid var(--cyan);
    padding: 15px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 1.1em;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
    transition: all 0.2s;
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

button:hover {
    background: var(--cyan); color: #000; box-shadow: 0 0 15px var(--cyan);
}

/* --- 5. DASHBOARD --- */
.telemetry-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px;
}
.stat-card {
    text-align: center; padding: 15px 5px;
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
.stat-card .value {
    font-size: 2.5em; font-weight: 700; color: var(--text-white); text-shadow: 0 0 10px var(--cyan);
}
.stat-card .label { font-size: 0.7em; color: #888; letter-spacing: 1px; }
.stat-card .unit { font-size: 0.8em; color: var(--orange); font-weight: bold; }

/* --- 6. HANGAR --- */
.device-row { display: flex; justify-content: space-between; align-items: center; }
.battery-bar {
    width: 100px; height: 10px; background: #333;
    display: inline-block; margin-right: 10px; border: 1px solid #555;
}
.battery-bar .fill { height: 100%; background: var(--success); box-shadow: 0 0 5px var(--success); }
.battery-bar .fill.alert { background: var(--orange); box-shadow: 0 0 5px var(--orange); }

/* --- 7. BARRACKS --- */
.rank-header {
    background: rgba(0,0,0,0.3); padding: 15px; border: 1px solid #333; margin-bottom: 20px;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%);
}
.rank-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
#rank-title { margin: 0; font-size: 1.8em; color: var(--cyan); text-shadow: 0 0 10px rgba(0, 240, 255, 0.5); border: none; }
.level-badge {
    background: var(--orange); color: #000; padding: 2px 8px;
    font-weight: bold; font-size: 1.2em;
    clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%);
}
.xp-container {
    width: 100%; position: relative; height: 25px;
    background: #111; border: 1px solid #444; margin-top: 5px;
}
.xp-fill {
    height: 100%; background: linear-gradient(90deg, rgba(0, 240, 255, 0.6), rgba(0, 150, 255, 0.8));
    width: 0%; transition: width 2s cubic-bezier(0.22, 1, 0.36, 1); position: absolute; top: 0; left: 0;
}
.xp-text-overlay {
    position: absolute; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
    z-index: 2; font-size: 0.9em; font-weight: bold; color: #fff;
    text-shadow: 0 0 4px #000; letter-spacing: 1px;
}

/* --- 8. COMPACT RIBBONS (Fixed Sizing) --- */
.ribbon-rack { 
    display: grid; 
    /* CHANGED: Increased min-width from 160px to 210px to fit long names */
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); 
    gap: 8px; 
    margin-bottom: 20px; 
}

.ribbon {
    background: #1a1a1a; 
    border: 1px solid #333; 
    height: 28px; 
    display: flex; 
    align-items: center; 
    justify-content: space-between;
    padding: 0;         
    padding-left: 10px;  
    position: relative; 
    overflow: hidden;    /* Ensures text doesn't spill out */
    margin-bottom: 2px; 
}

.ribbon-name { 
    font-size: 0.7em; 
    font-weight: 700; 
    color: #555; 
    letter-spacing: 1px; 
    white-space: nowrap;      /* Keep on one line */
    overflow: hidden;         /* Hide spillover */
    text-overflow: ellipsis;  /* Add "..." if it's STILL too long */
    margin-right: 5px;        /* Buffer from the XP tag */
}

/* --- NEW: XP TAG (Replaces old Checkmark) --- */
/* 1. Kill the old Checkmark Box if it exists */
.ribbon::after {
    content: none !important; 
    display: none;
}


/* 2. Style the new XP Tag */
.ribbon-xp {
    font-size: 0.75em; 
    font-weight: 800;
    color: var(--orange); 
    background: rgba(255, 85, 0, 0.15); 
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border-left: 1px solid var(--orange);
    min-width: 50px; 
    letter-spacing: 0.5px;
    
    /* NEW: Prevent the tag from getting squished by long names */
    flex-shrink: 0; 
}

/* --- RARITY GLOWS --- */
/* Common (Gray/Standard) */
.ribbon.common { border-left: 3px solid #555; }

/* Rare (Blue) */
.ribbon.rare { 
    border-left: 3px solid var(--cyan); 
    box-shadow: -5px 0 10px rgba(0, 240, 255, 0.1);
}
.ribbon.rare .ribbon-name { color: var(--cyan); }

/* Epic (Purple) */
.ribbon.epic { 
    border-left: 3px solid #D946EF; 
    box-shadow: -5px 0 15px rgba(217, 70, 239, 0.2);
}
.ribbon.epic .ribbon-name { color: #D946EF; }

/* Legendary (Gold) */
.ribbon.legendary { 
    border-left: 3px solid #FFD700;
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.05), transparent);
    animation: pulseGold 2s infinite;
}
.ribbon.legendary .ribbon-name { color: #FFD700; text-shadow: 0 0 5px rgba(255, 215, 0, 0.5); }
.ribbon.legendary .ribbon-xp {
    color: #FFD700;
    border-left-color: #FFD700;
    background: rgba(255, 215, 0, 0.15);
}

@keyframes pulseGold {
    0% { border-left-color: #FFD700; }
    50% { border-left-color: #FFF; }
    100% { border-left-color: #FFD700; }
}

/* --- THE NUCLEAR FLASH (Ceremony) --- */
.ribbon.ceremony-flash {
    animation: nuclearPulse 1.2s cubic-bezier(0.1, 0.7, 1.0, 0.1);
    z-index: 999;
    border-color: #fff !important;
}
@keyframes nuclearPulse {
    0% { transform: scale(1); background: #fff; }
    10% { transform: scale(1.4); background: #fff; color: #000; box-shadow: 0 0 50px var(--cyan), 0 0 100px #fff; }
    50% { transform: scale(1.4); background: #fff; box-shadow: 0 0 20px var(--cyan); }
    100% { transform: scale(1); background: #1a1a1a; }
}
.ribbon.ceremony-flash .ribbon-name,
.ribbon.ceremony-flash .ribbon-xp {
    color: #000 !important; 
    text-shadow: none !important;
    border-color: #000 !important;
}

/* --- 9. MEDALS --- */
/* --- MEDAL CASE UPDATES --- */
.medal-shelf {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 per row */
    gap: 10px;
    background: rgba(0,0,0,0.3); 
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #333;
}

.medal {
    width: 60px; height: 60px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8em; margin: 0 auto;
    border: 2px solid #333; 
    background: #111;
    transition: all 0.3s ease;
}

/* LOCKED STATE */
.medal.locked {
    filter: grayscale(100%);
    opacity: 0.5;
    color: #555;
    box-shadow: inset 0 0 10px #000;
}

/* EARNED STATE */
.medal.earned {
    border-color: #FFD700; /* Gold Border */
    color: #fff;
    background: radial-gradient(circle at 30% 30%, #444, #000);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3); /* Gold Glow */
    transform: scale(1.1);
}

.medal-slot {
    text-align: center;
}

/* --- 10. NAV & MODALS --- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; width: 100%;
    background: rgba(0, 0, 0, 0.9); display: flex; height: 70px;
    border-top: 2px solid #333; z-index: 10;
}
.nav-btn {
    flex: 1; background: transparent; color: #666; border: none;
    font-size: 1em; margin: 0; border-right: 1px solid #222;
}
.nav-btn.active {
    color: var(--orange);
    background: linear-gradient(to top, rgba(255, 85, 0, 0.2), transparent);
    border-top: 2px solid var(--orange);
    text-shadow: 0 0 8px var(--orange);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); z-index: 1000;
    display: flex; justify-content: center; align-items: center;
    backdrop-filter: blur(5px);
}
.hidden { display: none !important; }
.modal-panel {
    width: 90%; max-width: 400px; background: #111;
    border: 1px solid var(--cyan); padding: 20px;
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.2);
}
.modal-img-container img { width: 100px; height: 100px; display: block; margin: 0 auto; }

/* --- 11. PATCH GRID --- */
.patch-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 10px;
}
.patch-slot { display: flex; flex-direction: column; align-items: center; }
.patch-img { width: 100%; height: 100%; object-fit: contain; }
.patch { width: 70px; height: 70px; display: flex; align-items: center; justify-content: center; }
.patch.locked .patch-img { filter: grayscale(100%) brightness(0.5); opacity: 0.5; }
.patch.earned .patch-img { filter: drop-shadow(0 0 8px var(--cyan)); }
.patch-label { font-size: 0.6em; margin-top: 5px; color: #666; }
.patch.earned + .patch-label { color: var(--cyan); font-weight: 700; }

/* --- 12. UPLOAD ZONES (Consolidated) --- */
.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two equal columns */
    gap: 10px;
    margin-top: 10px;
}

.upload-zone {
    border: 2px dashed #444; 
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px; 
    padding: 15px 5px; 
    text-align: center;
    cursor: pointer; 
    position: relative; 
    overflow: hidden;
    margin-bottom: 0; 
    height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.zone-icon {
    font-size: 1.8rem; /* Smaller icon */
    margin-bottom: 5px;
}

.upload-zone h4 {
    font-size: 0.9rem; /* Smaller Title */
    margin: 0;
    color: var(--cyan);
}

.upload-zone p {
    font-size: 0.65rem; /* Tiny subtitle */
    line-height: 1.1;
    margin-top: 3px;
    max-width: 90%;
    color: #888;
}

.progress-fill {
    position: absolute; top: 0; left: 0; height: 100%; width: 0%;
    background: rgba(0, 240, 255, 0.2); transition: width 0.5s ease-out; z-index: 1;
}
.content-layer { position: relative; z-index: 2; }
.divider-text { display: none; }
.highlight-orange { color: var(--orange); }

/* --- LOCKED STATE --- */
.upload-zone.locked {
    opacity: 0.3;              
    pointer-events: none;      
    filter: grayscale(100%);   
    border-color: #333;        
    transition: all 0.3s;
}

/* Success State Style */
.upload-zone.success {
    border-style: solid;
    border-color: var(--success);
}
.upload-zone.success .progress-fill {
    background: rgba(0, 255, 65, 0.25);
}
.upload-zone.success h4 {
    color: var(--success);
}

/* --- 13. ORIGIN CARDS --- */
.origin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.origin-card {
    background: rgba(255, 255, 255, 0.05); border: 1px solid #444;
    border-radius: 6px; padding: 15px; text-align: center;
}
.origin-img { width: 90%; max-width: 160px; height: auto; }
.origin-card.locked { filter: grayscale(100%) opacity(0.4); }
.origin-card.ronin:not(.locked) .origin-img { filter: drop-shadow(0 0 15px var(--orange)); }
.origin-card.academy:not(.locked) .origin-img { filter: drop-shadow(0 0 15px var(--cyan)); }

/* Input Styles */
textarea {
    width: 100%; background: rgba(0, 0, 0, 0.5); border: 1px solid #444;
    color: var(--text-white); padding: 10px; box-sizing: border-box;
}
select {
    width: 100%; background: #111; border: 1px solid #444;
    color: var(--cyan); padding: 12px;
}

@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-5px); }
  100% { transform: translateX(0); }
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- CEREMONY ANIMATIONS --- */

/* --- THE NUCLEAR FLASH --- */
.ribbon.ceremony-flash {
    animation: nuclearPulse 1.2s cubic-bezier(0.1, 0.7, 1.0, 0.1);
    z-index: 999; /* Force it on top of everything */
    position: relative;
    border-color: #fff !important;
}

@keyframes nuclearPulse {
    0% {
        transform: scale(1);
        background: #fff;
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
    }
    10% {
        transform: scale(1.4); /* Massive Pop */
        background: #fff;
        color: #000; /* Invert text color for readability */
        box-shadow: 0 0 50px var(--cyan), 0 0 100px #fff; /* Double Glow */
    }
    50% {
        transform: scale(1.4); 
        background: #fff;
        box-shadow: 0 0 20px var(--cyan);
    }
    100% {
        transform: scale(1);
        background: #1a1a1a;
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    }
}

/* Ensure text is visible during the white flash */
.ribbon.ceremony-flash .ribbon-name {
    color: #000 !important; 
    text-shadow: none !important;
}

/* 2. The Rank Slam Overlay (The Level Up Event) */
#rank-up-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95); z-index: 2000;
    display: flex; flex-direction: column; 
    justify-content: center; align-items: center;
    opacity: 0; pointer-events: none; transition: opacity 0.5s;
}
#rank-up-overlay.active { opacity: 1; pointer-events: all; }

/* The Badge Slam Physics */
.rank-slam-anim {
    width: 200px; height: 200px;
    filter: drop-shadow(0 0 30px var(--orange));
    animation: bigSlam 1.2s cubic-bezier(0.2, 0.8, 0.2, 1.2) forwards;
}

@keyframes bigSlam {
    0% { transform: scale(10); opacity: 0; } /* Start Huge */
    40% { transform: scale(1); opacity: 1; }  /* SLAM! */
    60% { transform: scale(1.2); }            /* Bounce */
    100% { transform: scale(1); }             /* Settle */
}

.rank-up-text {
    font-size: 3rem; color: var(--orange); font-weight: bold;
    text-shadow: 0 0 20px var(--orange);
    margin-top: 20px;
    opacity: 0;
    animation: fadeInUp 1s ease 1s forwards; /* Delays text until after slam */
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- LOGIN PAGE STYLES --- */
.login-body {
    background: #000;
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(0, 240, 255, 0.1), transparent 60%),
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 100% 100%, 40px 40px, 40px 40px;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.login-card {
    width: 350px;
    background: rgba(10, 15, 20, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid var(--cyan);
    padding: 2px; /* For the double-border effect */
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.15);
    clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
    animation: floatCard 4s ease-in-out infinite;
}

@keyframes floatCard {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.login-header {
    background: rgba(0, 240, 255, 0.1);
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--cyan);
    margin-bottom: 20px;
}

.sub-brand {
    font-size: 0.8em;
    color: var(--orange);
    letter-spacing: 4px;
    font-weight: bold;
}

.login-form {
    padding: 20px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    color: #666;
    font-size: 0.7em;
    font-weight: bold;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.input-group input, .input-group select {
    width: 100%;
    background: #0a0e14;
    border: 1px solid #333;
    color: var(--text-white);
    padding: 12px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.1em;
    outline: none;
    transition: all 0.3s;
    /* Box sizing fix to prevent spilling out */
    box-sizing: border-box; 
}

.input-group input:focus, .input-group select:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.login-btn {
    background: var(--cyan);
    color: #000;
    width: 100%;
    padding: 15px;
    font-weight: 800;
    font-size: 1.2em;
    border: none;
    clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px);
    transition: all 0.2s;
}

.login-btn:hover {
    background: #fff;
    box-shadow: 0 0 20px var(--cyan);
    transform: scale(1.02);
}

.login-footer {
    text-align: center;
    font-size: 0.6em;
    color: #444;
    margin-top: 20px;
    letter-spacing: 2px;
}

/* Visibility Toggle */
.hidden { display: none; }