/* Professional School Timetable Variables */
:root {
    --primary-color: #2563eb; /* Trustworthy Blue */
    --accent-color: #f59e0b;
    --bg-color: #f8fafc;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
    --hover-bg: #f1f5f9;
    --success-color: #10b981;
    --error-color: #ef4444;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --card-bg: #1e293b;
    --hover-bg: #334155;
    --primary-color: #60a5fa;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    transition: background var(--transition), color var(--transition);
}

/* Header */
header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand .logo {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary-color);
}

.brand .tagline {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

select {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    font-weight: 600;
    cursor: pointer;
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: var(--card-bg);
    min-width: 180px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    z-index: 1000;
}

.dropdown:hover .dropdown-content { display: block; }

.dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    color: var(--text-color);
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: background var(--transition);
}

.dropdown-item:hover { background-color: var(--hover-bg); }

/* Main Layout */
main {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
    max-width: 1600px;
    margin: 2rem auto;
    padding: 0 2rem;
}

/* Form Panel */
.panel {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
    transition: border var(--transition);
}

input:focus { outline: none; border-color: var(--primary-color); }

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

.primary-btn:hover { opacity: 0.9; transform: translateY(-1px); }

/* Grid Panel */
.grid-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-wrapper {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #dcdcdc;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    min-width: 800px;
}

th, td {
    border: 1px solid #dcdcdc;
    padding: 0; /* Padding handled by card margin */
    text-align: center;
    position: relative;
    vertical-align: middle;
}

td {
    height: 110px;
    transition: background 0.2s;
}

td:hover {
    background-color: #fcfcfc;
}

th {
    padding: 1rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: #444;
}

/* Day-specific Header Colors (Refined Pastels) */
th:nth-child(2) { background-color: #f4d8de; } /* Mon */
th:nth-child(3) { background-color: #e6dff4; } /* Tue */
th:nth-child(4) { background-color: #e2f0d9; } /* Wed */
th:nth-child(5) { background-color: #fff2cc; } /* Thu */
th:nth-child(6) { background-color: #d9e1f2; } /* Fri */
th:nth-child(7) { background-color: #e2f0d9; } /* Sat */

.time-cell {
    width: 110px;
    background: #fdfdfd !important;
    font-size: 14px !important;
    color: #555 !important;
    font-weight: 600;
    padding: 5px !important;
    line-height: 1.3;
}

.period-num {
    display: block;
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 2px;
}

/* Class Block Card */
.class-block {
    background: var(--class-bg, var(--primary-color));
    color: #1e293b;
    margin: 8px;
    padding: 12px;
    border-radius: 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(255,255,255,0.3);
    height: calc(100% - 16px);
}

.class-block:hover {
    transform: scale(1.03);
    z-index: 5;
}

.class-block .name {
    font-weight: 850;
    font-size: 0.95rem;
    display: block;
    margin-bottom: 4px;
    line-height: 1.2;
}

.class-block .teacher, 
.class-block .room {
    font-size: 0.8rem;
    font-weight: 600;
    opacity: 0.85;
    display: block;
}

.card-icon {
    position: absolute;
    bottom: 8px;
    right: 8px;
    font-size: 1.4rem;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.9));
    opacity: 0.25;
    transition: all 0.3s ease;
    pointer-events: none;
}

.class-block:hover .card-icon {
    transform: scale(1.3) rotate(-15deg);
    opacity: 0.8;
}

.current-class {
    border: 3px solid var(--primary-color) !important;
    animation: breathing 2s infinite ease-in-out;
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.4);
}

@keyframes breathing {
    0% { transform: scale(1.0); opacity: 0.9; }
    50% { transform: scale(1.02); opacity: 1; }
    100% { transform: scale(1.0); opacity: 0.9; }
}

.live-status {
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.live-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    animation: pulse-green 1.5s infinite;
}

@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    opacity: 0;
    transition: opacity var(--transition);
}

.class-block:hover .delete-btn { opacity: 1; }

/* Empty State */
.empty-state {
    padding: 5rem 2rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state h2 { color: var(--text-color); margin-bottom: 1rem; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

/* Responsive */
@media (max-width: 1024px) {
    main { grid-template-columns: 1fr; }
    .panel { position: static; }
}

@media print {
    header, .panel, .grid-header, .delete-btn { display: none !important; }
    main { margin: 0; padding: 0; display: block; }
    table { border: 2px solid #000; }
    .class-block { border: 1px solid #ddd; }
}

/* --- Japanese 'Jikanwari' Print Theme --- */
.print-theme {
    background: #fff9f0 !important;
    font-family: 'Inter', cursive, sans-serif !important;
}

.print-theme main {
    grid-template-columns: 1fr;
    max-width: 1000px;
}

.print-theme .panel, 
.print-theme header,
.print-theme #openAutoGenModal,
.print-theme .delete-btn,
.print-theme .dropdown,
.print-theme #darkModeToggle {
    display: none !important;
}

.print-theme .grid-panel {
    background: white;
    padding: 2rem;
    border: 8px solid #ffdeeb;
    border-radius: 40px;
    position: relative;
}

.jikanwari-header {
    display: none;
    text-align: center;
    margin-bottom: 2rem;
}

.print-theme .jikanwari-header {
    display: block;
}

.jikanwari-title {
    font-size: 3rem;
    font-weight: 900;
    color: #ff85a1;
    margin: 0;
    letter-spacing: 5px;
}

.decoration-icon {
    font-size: 2.5rem;
    position: absolute;
}

.print-theme .table-wrapper {
    border: 4px solid #ffdeeb;
    border-radius: 20px;
}

.print-theme th {
    background: #ffdeeb;
    color: #ff4d6d;
    font-size: 1rem;
    padding: 0.75rem;
}

.print-theme th:nth-child(7) { background-color: #d1f2eb; } /* Sat in print */

.print-theme .time-cell {
    background: #fff0f3;
    color: #ff4d6d;
    font-size: 1.5rem;
    width: 60px;
}

.print-theme .class-block {
    background: var(--class-bg) !important;
    border: 3px solid rgba(255,255,255,0.5);
    border-radius: 15px;
    text-align: center;
    justify-content: center;
    box-shadow: none;
}

.print-theme .class-block .name {
    font-size: 1.1rem;
    color: #1e293b;
}

.print-theme .class-block .teacher,
.print-theme .class-block .room {
    font-size: 0.8rem;
    color: #475569;
}

/* Sticker Decorations for Print */
.sticker {
    position: absolute;
    font-size: 2rem;
    z-index: 100;
    pointer-events: none;
    text-shadow: 0 0 15px rgba(255, 255, 255, 1), 0 0 30px rgba(255, 255, 255, 0.5);
    filter: drop-shadow(3px 3px 5px rgba(0,0,0,0.15));
}

.approval-section {
    display: none;
    margin-top: 2rem;
    padding: 2rem;
}

.print-theme .approval-section {
    display: flex;
    gap: 3rem;
}

@media print {
    .approval-section { display: flex; gap: 3rem; }
}

.signature-line {
    border-top: 2px solid #000;
    padding-top: 0.5rem;
    min-width: 200px;
    font-size: 0.8rem;
    font-weight: 700;
}

.signature-date {
    font-size: 0.8rem;
    font-weight: 700;
    padding-top: 0.5rem;
}
