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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* 헤더 영역 */
.header {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 30px;
}

h1 {
    text-align: center;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin: 0;
}

.header-login {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.header-login .admin-btn {
    padding: 8px 16px;
    font-size: 14px;
}

/* 과목 버튼 영역 */
.subject-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.subject-btn {
    padding: 14px 28px;
    font-size: 18px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.subject-btn:nth-child(1) { background: #ffebee; color: #c62828; }
.subject-btn:nth-child(2) { background: #e3f2fd; color: #1565c0; }
.subject-btn:nth-child(3) { background: #e8f5e9; color: #2e7d32; }
.subject-btn:nth-child(4) { background: #f3e5f5; color: #7b1fa2; }
.subject-btn:nth-child(5) { background: #fff8e1; color: #f57f17; }

.subject-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.subject-btn:nth-child(1).active { background: #e74c3c; color: white; }
.subject-btn:nth-child(2).active { background: #3498db; color: white; }
.subject-btn:nth-child(3).active { background: #27ae60; color: white; }
.subject-btn:nth-child(4).active { background: #9b59b6; color: white; }
.subject-btn:nth-child(5).active { background: #f39c12; color: white; }

/* 관리자 패널 */
.admin-panel {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.admin-panel h3 {
    margin-bottom: 15px;
    color: #333;
}

.admin-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 15px;
}

.admin-controls input {
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.admin-controls input:focus {
    outline: none;
    border-color: #667eea;
}

.admin-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.admin-btn.primary {
    background: #667eea;
    color: white;
}

.admin-btn.danger {
    background: #e74c3c;
    color: white;
}

.admin-btn.success {
    background: #27ae60;
    color: white;
}

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

/* 학생 명단 편집 */
.student-list-editor {
    margin-top: 15px;
}

.student-list-editor textarea {
    width: 100%;
    height: 100px;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 18px;
    resize: vertical;
}

.student-list-editor textarea:focus {
    outline: none;
    border-color: #667eea;
}

.editor-hint {
    color: #888;
    font-size: 12px;
    margin-top: 5px;
}

/* 카드 그리드 */
.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    padding: 15px 0;
}

/* 카드 스타일 */
.card {
    perspective: 1000px;
    height: 90px;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.card-front {
    background: white;
    color: #333;
    font-size: 22px;
    padding: 8px;
    text-align: center;
}

.card-back {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    font-size: 24px;
    transform: rotateY(180deg);
}

.card-back.group-1 { background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%); }
.card-back.group-2 { background: linear-gradient(135deg, #3498db 0%, #2980b9 100%); }
.card-back.group-3 { background: linear-gradient(135deg, #27ae60 0%, #1e8449 100%); }
.card-back.group-4 { background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%); }
.card-back.group-5 { background: linear-gradient(135deg, #f39c12 0%, #d68910 100%); }
.card-back.group-6 { background: linear-gradient(135deg, #1abc9c 0%, #16a085 100%); }

/* 전체보기 버튼 */
.view-all-btn {
    display: block;
    margin: 20px auto;
    padding: 15px 40px;
    font-size: 18px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    background: white;
    color: #667eea;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.view-all-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* 전체보기 모달 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    overflow-y: auto;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 1000px;
    width: 95%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
}

.modal-close:hover {
    color: #333;
}

.group-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.group-card {
    perspective: 1000px;
    min-height: 150px;
    height: auto;
    cursor: pointer;
}

.group-card-inner {
    position: relative;
    width: 100%;
    min-height: 150px;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.group-card.flipped .group-card-inner {
    transform: rotateY(180deg);
}

.group-card.show-all .group-card-inner {
    transform: rotateY(180deg);
}

.group-card-front, .group-card-back {
    position: absolute;
    width: 100%;
    min-height: 150px;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.group-card-front {
    font-size: 36px;
}

.group-card-back {
    position: relative;
    transform: rotateY(180deg);
    padding: 20px;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
}

.group-card-back h4 {
    margin-bottom: 10px;
    font-size: 22px;
    border-bottom: 2px solid rgba(255,255,255,0.3);
    padding-bottom: 8px;
    width: 100%;
}

.group-card-back ul {
    list-style: none;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.group-card-back li {
    padding: 5px 10px;
    font-size: 22px;
    background: transparent;
    border-radius: 5px;
    width: calc(50% - 3px);
    text-align: center;
    box-sizing: border-box;
}

.group-card:nth-child(6n+1) .group-card-front,
.group-card:nth-child(6n+1) .group-card-back { background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%); }
.group-card:nth-child(6n+2) .group-card-front,
.group-card:nth-child(6n+2) .group-card-back { background: linear-gradient(135deg, #3498db 0%, #2980b9 100%); }
.group-card:nth-child(6n+3) .group-card-front,
.group-card:nth-child(6n+3) .group-card-back { background: linear-gradient(135deg, #27ae60 0%, #1e8449 100%); }
.group-card:nth-child(6n+4) .group-card-front,
.group-card:nth-child(6n+4) .group-card-back { background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%); }
.group-card:nth-child(6n+5) .group-card-front,
.group-card:nth-child(6n+5) .group-card-back { background: linear-gradient(135deg, #f39c12 0%, #d68910 100%); }
.group-card:nth-child(6n+6) .group-card-front,
.group-card:nth-child(6n+6) .group-card-back { background: linear-gradient(135deg, #1abc9c 0%, #16a085 100%); }

.show-all-groups-btn {
    display: block;
    margin: 20px auto 0;
    padding: 12px 30px;
    font-size: 16px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    background: #667eea;
    color: white;
    font-weight: bold;
    transition: all 0.3s ease;
}

.show-all-groups-btn:hover {
    background: #5a6fd6;
    transform: translateY(-2px);
}

.pending-status {
    color: #e74c3c !important;
    font-weight: bold;
}

/* 로그인 모달 */
.login-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
}

.login-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: white;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
}

.login-box h3 {
    margin-bottom: 20px;
    color: #333;
}

.login-box input {
    padding: 12px 20px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    margin-bottom: 15px;
    width: 200px;
}

/* 모바일 브라우저(Edge/IE)의 비밀번호 공개 버튼 숨김 */
.login-box input[type="password"]::-ms-reveal,
.login-box input[type="password"]::-ms-clear {
    display: none;
}

/* 암호 입력 + 눈 아이콘 래퍼 */
.pw-input-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: 15px;
}

.pw-input-wrap input {
    margin-bottom: 0;
    padding-right: 44px;
    width: 200px;
}

.login-box .pw-toggle-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: #666;
    z-index: 1;
    border-radius: 4px;
}

.login-box button {
    padding: 12px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
}

.login-error {
    color: #e74c3c;
    margin-top: 10px;
    font-size: 14px;
}

/* 안내 메시지 */
.guide-message {
    text-align: center;
    color: rgba(255,255,255,0.9);
    font-size: 18px;
    padding: 15px 25px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    border: 2px dashed rgba(255,255,255,0.3);
    grid-column: 1 / -1;
    justify-self: center;
    width: fit-content;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .guide-message {
        white-space: normal;
        font-size: 16px;
        padding: 12px 15px;
        width: auto;
        justify-self: stretch;
    }

    /* 헤더 모바일 대응 */
    .header {
        flex-direction: column;
        gap: 15px;
    }

    h1 {
        font-size: 1.3rem;
    }

    .header-login {
        position: static;
        transform: none;
        display: flex;
        flex-direction: row;
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .header-login .admin-btn {
        padding: 8px 12px;
        font-size: 13px;
        margin-top: 0 !important;
    }
}

/* 과목명 수정 */
.subject-edit-area {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.subject-edit-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.subject-edit-header h4 {
    margin: 0;
    color: #666;
}

.subject-edit-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.subject-edit-row input {
    width: 150px;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

/* 과목 정보 표시 */
.subject-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
    text-align: center;
}

.subject-info .info-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
}

.subject-info .info-detail {
    font-size: 16px;
    color: #666;
}

.subject-info .info-detail span {
    font-weight: bold;
    color: #667eea;
}

/* 푸터 */
.footer {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    color: rgba(255,255,255,0.8);
    font-size: 14px;
}

.footer a {
    color: white;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* 조편성 원칙 모달 스타일 */
.rules-content h3 {
    color: #333;
    margin: 20px 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 2px solid #667eea;
}

.rules-content ul {
    margin: 10px 0;
    padding-left: 20px;
}

.rules-content li {
    margin: 8px 0;
    line-height: 1.6;
}

.rules-content p {
    margin: 10px 0;
    line-height: 1.6;
}

.rules-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.rules-table th, .rules-table td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: center;
}

.rules-table th {
    background: #667eea;
    color: white;
}

.rules-table tr:nth-child(even) {
    background: #f8f9fa;
}

.rules-example {
    background: #e8f4fd;
    border-left: 4px solid #3498db;
    padding: 10px 15px;
    margin: 10px 0;
    border-radius: 0 8px 8px 0;
}

.rules-example p {
    margin: 5px 0;
}

/* 교수님 암호 수정 스타일 */
.admin-pw-input {
    width: 120px;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}
