/* ==========================================================
   ClassPet Quest – 16-Bit Pixel-Art Theme
   (Streamlit-unabhängig, migrated to FastAPI + Jinja2)
   ========================================================== */

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 12px;
    color: #e0e0e0;
    background: #0f0f1a;
    background-image: radial-gradient(ellipse at top, #1a1a3e 0%, #0f0f1a 60%);
    min-height: 100vh;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #1a1a2e; }
::-webkit-scrollbar-thumb { background: #4a4a8a; border-radius: 4px; }

/* ---- Headings ---- */
h1, h2, h3, h4 {
    color: #f0d060;
    text-shadow: 3px 3px 0 #8a6000, -1px -1px 0 #3a2000;
    letter-spacing: 1px;
    margin: 0.6em 0 0.3em;
}

hr { border: none; border-top: 2px solid #3a3a6a; margin: 12px 0; }

a { color: #6a9aff; text-decoration: none; }
a:hover { text-decoration: underline; }

code {
    background: #12122a;
    border: 1px solid #3a3a6a;
    padding: 1px 4px;
    border-radius: 2px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
}

/* ---- App layout ---- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f0f1a;
}

/* ---- Sidebar ---- */
.sidebar {
    width: 260px;
    min-height: 100vh;
    background: #12122a;
    border-right: 3px solid #3a3a6a;
    padding: 20px 14px;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-name {
    font-size: 11px;
    color: #f0d060;
    margin-bottom: 10px;
}

.sidebar-pet-name {
    font-size: 10px;
    color: #ccccff;
    text-align: center;
    margin: 6px 0;
}

.sidebar-metric {
    font-size: 9px;
    color: #aaaacc;
    margin: 8px 0;
}

.sidebar-expander > summary {
    cursor: pointer;
    font-size: 9px;
    color: #8888cc;
    list-style: none;
    padding: 4px 0;
}

/* ---- Main content ---- */
.main-content {
    flex: 1;
    padding: 24px 32px;
    overflow-x: auto;
}

/* ---- Pixel Panel ---- */
.pixel-panel {
    background: #1e1e3a;
    border: 3px solid #4a4a8a;
    border-radius: 4px;
    padding: 16px;
    box-shadow: 4px 4px 0 #0a0a18, inset 0 0 0 1px #2e2e5a;
    margin-bottom: 12px;
}

/* ---- Buttons ---- */
.btn-pixel {
    background: #3a3a7a;
    color: #f0d060;
    border: 3px solid #6a6aba;
    border-radius: 0;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 8px 16px;
    box-shadow: 3px 3px 0 #1a1a3a;
    cursor: pointer;
    transition: transform 0.05s, box-shadow 0.05s;
    text-decoration: none;
    display: inline-block;
    line-height: 1.4;
}
.btn-pixel:hover {
    background: #5a5aaa;
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 #1a1a3a;
    text-decoration: none;
    color: #f0d060;
}
.btn-pixel:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 #1a1a3a;
}
.btn-pixel:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-sm  { font-size: 9px;  padding: 5px 10px; }
.btn-xs  { font-size: 8px;  padding: 3px 8px;  }
.btn-full { width: 100%; text-align: center; }

.btn-danger  { background: #7a1a1a !important; border-color: #ba4a4a !important; }
.btn-success { background: #1a5a1a !important; border-color: #4aba4a !important; }

.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn-col { display: flex; flex-direction: column; gap: 4px; }

/* ---- Form elements ---- */
label {
    display: block;
    font-size: 9px;
    color: #aaaacc;
    margin-bottom: 8px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="email"],
input[type="file"],
textarea,
select {
    display: block;
    width: 100%;
    background: #12122a;
    border: 2px solid #4a4a8a;
    border-radius: 0;
    color: #e0e0e0;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 6px 8px;
    margin-top: 4px;
}
input[type="checkbox"] { width: auto; display: inline; margin-right: 6px; }

textarea { resize: vertical; min-height: 70px; }

select option { background: #12122a; }

.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 8px;
}
.form-row > label { flex: 1; min-width: 140px; }

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.inline-form input, .inline-form select { width: auto; min-width: 120px; }

/* ---- Flash / Alert messages ---- */
.flash {
    padding: 10px 14px;
    margin: 8px 0;
    border-radius: 2px;
    font-size: 9px;
    border-left: 4px solid;
}
.flash-success { background: #0a2a0a; border-color: #2a8a2a; color: #88ff88; }
.flash-error   { background: #2a0a0a; border-color: #8a2a2a; color: #ff8888; }
.flash-warning { background: #2a1a0a; border-color: #8a5a0a; color: #ffcc88; }
.flash-info    { background: #0a1a2a; border-color: #2a5a8a; color: #88aaff; }

.info-box {
    background: #0a1a2a;
    border: 1px solid #2a5a8a;
    padding: 10px 14px;
    border-radius: 2px;
    font-size: 9px;
    color: #88aaff;
    margin: 8px 0;
}

/* ---- Tab navigation ---- */
.tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    background: #12122a;
    border-bottom: 3px solid #4a4a8a;
    padding: 4px 4px 0;
    margin-bottom: 16px;
}
.tab-link {
    background: #1e1e3a;
    color: #8888cc;
    border: 2px solid #3a3a6a;
    border-bottom: none;
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    padding: 8px 12px;
    text-decoration: none;
    display: inline-block;
}
.tab-link:hover { background: #2e2e5a; color: #ccccff; text-decoration: none; }
.tab-link.active {
    background: #3a3a7a;
    color: #f0d060;
    border-color: #6a6aba;
    border-bottom: 3px solid #3a3a7a;
    margin-bottom: -3px;
}
.sub-tabs { margin-top: 8px; background: #1a1a2e; border-color: #3a3a6a; }

/* ---- Tables ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9px;
    border: 2px solid #4a4a8a;
}
.data-table th {
    background: #1e1e3a;
    color: #f0d060;
    padding: 6px 8px;
    border: 1px solid #3a3a6a;
    text-align: left;
    white-space: nowrap;
}
.data-table td {
    padding: 5px 8px;
    border: 1px solid #2a2a4a;
    vertical-align: middle;
}
.data-table tr:nth-child(even) { background: #14142a; }
.data-table tr:hover { background: #1e1e3e; }

/* ---- Stat bars ---- */
.stat-bar-container {
    width: 100%;
    background: #12122a;
    border: 2px solid #3a3a6a;
    height: 14px;
    border-radius: 2px;
    overflow: hidden;
    margin: 4px 0;
}
.stat-bar {
    height: 100%;
    transition: width 0.5s ease;
    image-rendering: pixelated;
}
.bar-hp      { background: linear-gradient(90deg, #cc2222, #ff4444); }
.bar-hunger  { background: linear-gradient(90deg, #cc8800, #ffcc00); }
.bar-xp      { background: linear-gradient(90deg, #2255cc, #44aaff); }
.stat-label {
    font-size: 8px;
    color: #aaaacc;
    margin: 2px 0;
}

/* ---- Quest cards ---- */
.quest-card {
    background: #1a1a2e;
    border: 2px solid #3a3a6a;
    border-left: 4px solid #6a6aba;
    padding: 12px;
    margin: 8px 0;
    border-radius: 2px;
}
.quest-card.completed { border-left-color: #4a8a4a; opacity: 0.7; }
.quest-card.pending   { border-left-color: #8a8a2a; }
.quest-link { font-size: 9px; color: #6a9aff; }
.caption    { font-size: 8px; color: #8888aa; margin: 4px 0; }

/* ---- Loss log ---- */
.loss-log {
    background: #2a0a0a;
    border: 1px solid #8a2a2a;
    padding: 8px 12px;
    border-radius: 2px;
    margin: 8px 0;
    font-size: 9px;
}
.loss-log > summary { cursor: pointer; color: #ff8888; }
.loss-entry {
    background: #2a0a0a;
    border-left: 3px solid #cc4444;
    padding: 4px 8px;
    margin: 4px 0;
    font-size: 9px;
}

/* ---- Prestige banner ---- */
.prestige-banner {
    background: #2a1a00;
    border: 2px solid #FF9800;
    padding: 12px;
    border-radius: 4px;
    text-align: center;
    margin-bottom: 12px;
    font-size: 11px;
}

/* ---- Weekly planner ---- */
.planner-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}
.planner-col { min-width: 0; }
.planner-day-header {
    font-size: 9px;
    color: #ccccff;
    font-weight: bold;
    text-align: center;
    margin-bottom: 6px;
}
.planner-today { color: #f0d060 !important; }
.planner-assign-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin: 6px 0;
    padding: 6px;
    background: #1a1a2a;
    border-left: 3px solid #4a4a8a;
}
.planner-assign-row select { width: auto; min-width: 100px; }

/* ---- Shop ---- */
.shop-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 8px 0;
}
.shop-item {
    background: #1a1a2e;
    border: 2px solid #3a3a6a;
    padding: 12px;
    text-align: center;
    border-radius: 4px;
    width: 140px;
}
.shop-price { color: #f0d060; font-size: 11px; margin-top: 6px; }
.shop-section > summary {
    cursor: pointer;
    font-size: 10px;
    color: #ccccff;
    padding: 6px 4px;
}

/* ---- Class expander ---- */
.class-expander > summary {
    cursor: pointer;
    font-size: 10px;
    color: #ccccff;
    padding: 4px 0;
}

/* ---- Login page ---- */
.login-box {
    max-width: 440px;
    width: 100%;
    background: #1e1e3a;
    border: 3px solid #4a4a8a;
    padding: 32px;
    box-shadow: 6px 6px 0 #0a0a18;
    margin: 20px;
}
.game-title {
    text-align: center;
    font-size: 20px;
    color: #f0d060;
    text-shadow: 3px 3px 0 #8a6000;
    margin-bottom: 8px;
    line-height: 1.6;
}
.game-subtitle {
    text-align: center;
    font-size: 9px;
    color: #8888cc;
    margin-bottom: 16px;
}

/* CSS-only login tabs using radio buttons */
.login-tabs {
    display: flex;
    flex-wrap: wrap;
}

.login-tabs input[type="radio"] { display: none; }

.login-tabs > label {
    flex: 0 0 50%;
    box-sizing: border-box;
    padding: 10px 0;
    font-size: 9px;
    text-align: center;
    color: #8888cc;
    background: #1e1e3a;
    border: 2px solid #3a3a6a;
    cursor: pointer;
}
.login-tabs > label:hover { background: #2e2e5a; color: #ccccff; }

#lt-student:checked ~ label[for="lt-student"],
#lt-teacher:checked ~ label[for="lt-teacher"] {
    background: #3a3a7a;
    color: #f0d060;
    border-color: #6a6aba;
}

/* Hide all panels by default */
.lt-panel { display: none; flex: 0 0 100%; padding-top: 16px; }

/* Show the panel whose radio is checked */
#lt-student:checked ~ #lp-student,
#lt-teacher:checked ~ #lp-teacher { display: block; }

/* ---- Info widget (top-right "i" button) ---- */
.info-widget {
    position: fixed;
    top: 12px;
    right: 14px;
    z-index: 999;
    font-family: 'Press Start 2P', monospace;
}
.info-widget summary {
    list-style: none;
    width: 22px;
    height: 22px;
    line-height: 20px;
    text-align: center;
    font-size: 11px;
    color: #8888cc;
    border: 2px solid #3a3a6a;
    background: #1e1e3a;
    cursor: pointer;
    border-radius: 50%;
    user-select: none;
}
.info-widget summary::-webkit-details-marker { display: none; }
.info-widget summary:hover { background: #2e2e5a; color: #ccccff; border-color: #6a6aba; }
.info-widget[open] summary { color: #f0d060; border-color: #6a6aba; background: #3a3a7a; }
.info-widget-panel {
    position: absolute;
    top: 30px;
    right: 0;
    min-width: 200px;
    background: #1e1e3a;
    border: 2px solid #4a4a8a;
    padding: 14px 16px;
    box-shadow: 4px 4px 0 #0a0a18;
    font-size: 8px;
    line-height: 2.2;
    color: #aaaadd;
}
.info-widget-panel p { margin: 0; }
.info-widget-panel a { color: #f0d060; text-decoration: none; }
.info-widget-panel a:hover { text-decoration: underline; }
.info-widget-panel hr { border-color: #3a3a6a; margin: 8px 0; }

/* ---- Rarity colors ---- */
.rarity-Common    { color: #9E9E9E; }
.rarity-Uncommon  { color: #4CAF50; }
.rarity-Rare      { color: #2196F3; }
.rarity-Epic      { color: #CE93D8; }
.rarity-Legendary { color: #FF9800; text-shadow: 0 0 8px #FF9800; }

/* ---- Adventure timer ---- */
.adventure-timer {
    font-size: 14px;
    color: #f0d060;
    text-align: center;
    padding: 16px;
    border: 3px solid #6a6aba;
    background: #1a1a2e;
    animation: sparkle 2s ease-in-out infinite;
    margin-bottom: 12px;
}

/* ==========================================================
   Pet Animations
   ========================================================== */

@keyframes float {
    0%   { transform: translateY(0px); }
    50%  { transform: translateY(-12px); }
    100% { transform: translateY(0px); }
}
@keyframes breathe {
    0%   { transform: scale(1.00); }
    50%  { transform: scale(1.06); }
    100% { transform: scale(1.00); }
}
@keyframes sparkle {
    0%   { opacity: 1; }
    50%  { opacity: 0.4; }
    100% { opacity: 1; }
}
@keyframes pixel-glow {
    0%   { filter: drop-shadow(0 0 3px #f0d06088); }
    50%  { filter: drop-shadow(0 0 7px #f0d060cc); }
    100% { filter: drop-shadow(0 0 3px #f0d06088); }
}
@keyframes egg-pulse {
    0%   { transform: scale(1.00); filter: brightness(1.0); }
    40%  { transform: scale(1.08); filter: brightness(1.3); }
    60%  { transform: scale(1.08); filter: brightness(1.3); }
    100% { transform: scale(1.00); filter: brightness(1.0); }
}
@keyframes sparkle-border {
    0%   { box-shadow: 0 0 6px 2px #ffd700aa, 0 0 0 2px #ffd700; }
    25%  { box-shadow: 0 0 14px 4px #fffaaacc, 0 0 0 2px #ffd700; }
    50%  { box-shadow: 0 0 6px 2px #ffd700aa, 0 0 0 2px #ffd700; }
    75%  { box-shadow: 0 0 18px 6px #ffd700ff, 0 0 0 2px #fffaaa; }
    100% { box-shadow: 0 0 6px 2px #ffd700aa, 0 0 0 2px #ffd700; }
}
@keyframes orbit1 {
    from { transform: rotate(0deg)   translateX(52px) rotate(0deg);   }
    to   { transform: rotate(360deg) translateX(52px) rotate(-360deg); }
}
@keyframes orbit2 {
    from { transform: rotate(120deg)  translateX(44px) rotate(-120deg); }
    to   { transform: rotate(480deg)  translateX(44px) rotate(-480deg); }
}
@keyframes orbit3 {
    from { transform: rotate(240deg)  translateX(60px) rotate(-240deg); }
    to   { transform: rotate(600deg)  translateX(60px) rotate(-600deg); }
}
@keyframes orbit4 {
    from { transform: rotate(60deg)   translateX(48px) rotate(-60deg);  }
    to   { transform: rotate(420deg)  translateX(48px) rotate(-420deg); }
}
@keyframes orbit5 {
    from { transform: rotate(300deg)  translateX(56px) rotate(-300deg); }
    to   { transform: rotate(660deg)  translateX(56px) rotate(-660deg); }
}
@keyframes particle-twinkle {
    0%, 100% { opacity: 1; transform: scale(1);   }
    50%       { opacity: 0.3; transform: scale(0.4); }
}
@keyframes rarity-glow-common    { 0%,100% { filter: drop-shadow(0 0 3px #9E9E9E55); } 50% { filter: drop-shadow(0 0 6px #9E9E9Eaa); } }
@keyframes rarity-glow-uncommon  { 0%,100% { filter: drop-shadow(0 0 3px #4CAF5055); } 50% { filter: drop-shadow(0 0 7px #4CAF50aa); } }
@keyframes rarity-glow-rare      { 0%,100% { filter: drop-shadow(0 0 4px #2196F355); } 50% { filter: drop-shadow(0 0 8px #2196F3aa); } }
@keyframes rarity-glow-epic      { 0%,100% { filter: drop-shadow(0 0 4px #CE93D855); } 50% { filter: drop-shadow(0 0 9px #CE93D8cc); } }
@keyframes rarity-glow-legendary { 0%,100% { filter: drop-shadow(0 0 5px #FF980077); } 50% { filter: drop-shadow(0 0 11px #FF9800dd); } }

/* Bob animation – quick, snappy vertical bounce for sidebar pet */
@keyframes bob {
    0%,100% { transform: translateY(0px);   }
    20%     { transform: translateY(-5px);  }
    40%     { transform: translateY(0px);   }
    60%     { transform: translateY(-3px);  }
    80%     { transform: translateY(0px);   }
}

/* Applied animation classes */
.pet-float    { animation: float 3s ease-in-out infinite; display: inline-block; }
.pet-breathe  { animation: breathe 4s ease-in-out infinite; display: inline-block; }
.pet-legendary{ animation: float 3s ease-in-out infinite; display: inline-block; }
.pet-egg      { animation: egg-pulse 2.4s ease-in-out infinite; display: inline-block; }
.pet-shiny    { animation: sparkle-border 1.8s ease-in-out infinite; border-radius: 6px; display: inline-block; }
.pet-bob      { animation: bob 2s ease-in-out infinite; display: inline-block; }

.rarity-glow-Common    { animation: rarity-glow-common    3s ease-in-out infinite; display: inline-block; }
.rarity-glow-Uncommon  { animation: rarity-glow-uncommon  3s ease-in-out infinite; display: inline-block; }
.rarity-glow-Rare      { animation: rarity-glow-rare      3s ease-in-out infinite; display: inline-block; }
.rarity-glow-Epic      { animation: rarity-glow-epic      2.5s ease-in-out infinite; display: inline-block; }
.rarity-glow-Legendary { animation: rarity-glow-legendary 2s ease-in-out infinite; display: inline-block; }

/* ── Health state – applied to the image wrapper when HP is low ────────────
   The wrapper sits between the bob-animation container and the rarity glow,
   so the filter desaturation and wobble transform don't conflict with the
   outer bob (translateY) or the inner float (also translateY) animations.   */
.pet-ill {
    filter: saturate(0.6) brightness(0.9);
}
.pet-sick {
    filter: saturate(0.3) brightness(0.85) drop-shadow(0 0 4px rgba(100,200,100,0.5));
    animation: pet-wobble 2s ease-in-out infinite;
}
.pet-critical {
    /* position: relative is set inline in Python; repeated here as a safety net */
    position: relative;
    filter: saturate(0.15) brightness(0.8) drop-shadow(0 0 6px rgba(255,50,50,0.7));
    animation: pet-wobble 1s ease-in-out infinite;
}
.pet-critical::after {
    content: "🤒";
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    animation: float-icon 1.5s ease-in-out infinite;
}
@keyframes pet-wobble {
    0%, 100% { transform: rotate(-2deg); }
    50%       { transform: rotate(2deg); }
}
@keyframes float-icon {
    0%, 100% { transform: translateX(-50%) translateY(0px); }
    50%       { transform: translateX(-50%) translateY(-4px); }
}

.pet-room {
    position: relative;
    background: #1a3a6e;
    border-radius: 8px;
    padding: 24px 16px 16px;
    margin: 8px auto 12px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-height: 160px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.pet-prestige-wrap {
    position: relative;
    display: inline-block;
}
.pet-prestige-wrap .particle {
    position: absolute;
    top: 50%; left: 50%;
    width: 7px; height: 7px;
    border-radius: 1px;
    transform-origin: 0 0;
    animation: particle-twinkle 1.2s ease-in-out infinite;
}
.pet-prestige-wrap .p1 { background:#f0d060; animation: orbit1 2.8s linear infinite, particle-twinkle 1.1s ease-in-out infinite; }
.pet-prestige-wrap .p2 { background:#ff88ff; animation: orbit2 3.2s linear infinite, particle-twinkle 1.4s ease-in-out infinite 0.3s; }
.pet-prestige-wrap .p3 { background:#44ddff; animation: orbit3 2.5s linear infinite, particle-twinkle 0.9s ease-in-out infinite 0.6s; }
.pet-prestige-wrap .p4 { background:#ff6644; animation: orbit4 3.6s linear infinite, particle-twinkle 1.3s ease-in-out infinite 0.15s; }
.pet-prestige-wrap .p5 { background:#aaffaa; animation: orbit5 3.0s linear infinite, particle-twinkle 1.0s ease-in-out infinite 0.45s; }
