/* ===== CSS Variables (Theme System) ===== */
:root {
    /* Base Sci-Fi UI colors (Blue theme) */
    --bg-base: #10162A;
    --bg-darker: #080C17;
    --bg-panel: rgba(26, 38, 69, 0.7);
    --border-color: rgba(94, 166, 255, 0.3);
    --primary-color: #5ea6ff;
    --accent-color: #ffcc00;
    /* New task/alert accent */
    --text-main: #e0e6ed;
    --text-dim: rgba(224, 230, 237, 0.6);
    --danger-color: #ff4757;

    /* Progress bar gradient */
    --progress-grad: linear-gradient(90deg, rgba(30, 60, 120, 1) 0%, rgba(94, 166, 255, 1) 100%);
    --progress-stripes: repeating-linear-gradient(45deg,
            rgba(255, 255, 255, 0.1),
            rgba(255, 255, 255, 0.1) 10px,
            transparent 10px,
            transparent 20px);
}

/* Red Theme Override (Activated when progress > 100%) */
body.theme-red {
    --bg-base: #2a1010;
    --bg-darker: #170808;
    --bg-panel: rgba(80, 20, 20, 0.7);
    --border-color: rgba(255, 71, 87, 0.3);
    --primary-color: #ff4757;
    --progress-grad: linear-gradient(90deg, rgba(120, 30, 30, 1) 0%, rgba(255, 71, 87, 1) 100%);
}

/* ===== Global Reset & Basics ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--bg-darker);
    color: var(--text-main);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.8s ease;
}

/* Background Effects */
.background-grid {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(var(--border-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.1;
    z-index: -2;
    pointer-events: none;
}

.scanline {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0) 50%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.1));
    background-size: 100% 4px;
    z-index: -1;
    pointer-events: none;
    opacity: 0.4;
}

/* ===== Header ===== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(180deg, var(--bg-base) 0%, transparent 100%);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--accent-color);
    filter: drop-shadow(0 0 5px var(--accent-color));
}

.title-text {
    display: flex;
    flex-direction: column;
}

.title-text .sub {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.title-text .main {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.status-indicators {
    font-family: monospace;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 15px;
}

.icon-button {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--primary-color);
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-button:hover {
    background: var(--primary-color);
    color: var(--bg-base);
}

/* ===== Main Dashboard ===== */
.dashboard {
    padding: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Slanted visual elements typical of sci-fi UI */
.slanted {
    transform: skewX(-20deg);
}

.progress-section {
    margin-top: 2rem;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 0.5rem;
    padding: 0 5%;
}

.progress-header h2 {
    font-size: 1.5rem;
    font-weight: 300;
    letter-spacing: 2px;
    color: var(--text-dim);
}

.glitch-text {
    color: var(--primary-color);
    font-family: monospace;
}

body.theme-red .glitch-text {
    content: "추가숙제 진행중";
    font-weight: bold;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    0% {
        opacity: 0.8;
        text-shadow: 0 0 5px var(--primary-color);
    }

    100% {
        opacity: 1;
        text-shadow: 0 0 15px var(--primary-color), 0 0 25px var(--primary-color);
    }
}

.progress-container {
    position: relative;
    width: 90%;
    margin: 0 auto;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

.progress-bar-bg {
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 2px;
    right: 2px;
    background: #000;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--progress-grad);
    box-shadow: 0 0 15px var(--primary-color);
    position: relative;
    transition: width 1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: hidden;
}

.progress-stripes {
    position: absolute;
    top: 0;
    left: 0;
    right: -100px;
    bottom: 0;
    /* right: -100px ensures stripes cover even during width transition */
    background: var(--progress-stripes);
    animation: moveStripes 20s linear infinite;
    pointer-events: none;
}

@keyframes moveStripes {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 1000px 0;
    }
}

.progress-value {
    position: absolute;
    right: 5%;
    transform: skewX(20deg);
    /* Counter skew to keep text straight */
    font-size: 1.8rem;
    font-weight: 700;
    font-family: monospace;
    text-shadow: 0 0 5px #000;
}

/* Split Pane Area */
.details-section {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
    flex: 1;
}

.pane {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 4px;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.pane::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 30px;
    height: 30px;
    border-top: 2px solid var(--primary-color);
    border-left: 2px solid var(--primary-color);
}

.pane::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 30px;
    height: 30px;
    border-bottom: 2px solid var(--primary-color);
    border-right: 2px solid var(--primary-color);
}

.pane-left {
    flex: 1;
}

.pane-right {
    flex: 2;
}

.pane-title {
    color: var(--primary-color);
    margin-bottom: 1rem;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 0.5rem;
}

.pane-title-with-icon {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dim);
    margin-bottom: 1rem;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 0.5rem;
}

.homework-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.hw-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 15px;
    border-left: 3px solid var(--primary-color);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
}

.hw-item:hover,
.hw-item.active {
    background: rgba(255, 255, 255, 0.05);
    border-left-color: var(--accent-color);
}

.details-content {
    line-height: 1.6;
}

.placeholder-text {
    color: var(--text-dim);
    text-align: center;
    padding: 2rem;
    font-style: italic;
}

/* ===== Admin Specific UI ===== */
.admin-container {
    padding: 2rem;
    position: relative;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.auth-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    z-index: 100;
}

.auth-box {
    text-align: center;
    background: #000;
}

.auth-box p {
    margin: 10px 0 20px;
    color: var(--text-dim);
}

.hidden {
    display: none !important;
}

/* Forms */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.mt-grid {
    margin-top: 1.5rem;
}

h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.input-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.input-row {
    display: flex;
    gap: 10px;
}

label {
    font-size: 0.85rem;
    color: var(--text-dim);
}

input,
select {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 2px;
    font-family: inherit;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 5px rgba(94, 166, 255, 0.5);
}

.btn {
    padding: 10px 15px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    border-radius: 2px;
    transition: all 0.2s;
    width: 100%;
    margin-top: 5px;
}

.btn-primary {
    background: rgba(94, 166, 255, 0.2);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-color);
    color: #000;
}

.btn-accent {
    background: rgba(255, 204, 0, 0.2);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
}

.btn-accent:hover {
    background: var(--accent-color);
    color: #000;
}

.btn-danger {
    background: rgba(255, 71, 87, 0.2);
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

.btn-danger:hover {
    background: var(--danger-color);
    color: #fff;
}

.btn-danger-outline {
    background: transparent;
    border: 1px dashed var(--danger-color);
    color: var(--danger-color);
}

.btn-danger-outline:hover {
    background: rgba(255, 71, 87, 0.1);
}

.error-msg {
    color: var(--danger-color);
    font-size: 0.85rem;
    margin-top: 10px;
    min-height: 20px;
}

.help-text {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 1rem;
}

.text-danger {
    color: var(--danger-color);
}

.admin-alert-pane {
    border-color: rgba(255, 71, 87, 0.3);
}

.admin-alert-pane::before,
.admin-alert-pane::after {
    border-color: var(--danger-color);
}

.admin-alert-pane h3 {
    color: var(--danger-color);
}

/* Table */
.table-container {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-table th {
    color: var(--text-dim);
    font-weight: 500;
}