/* General Reset & Base Styles */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700&display=swap');

:root {
    --primary-color: #007aff;
    --primary-hover-color: #0056b3;
    --danger-color: #ff3b30;
    --danger-hover-color: #c50f0f;
    
    --bg-color: #f8f9fa;
    --secondary-bg-color: #ffffff;
    --text-color: #212529;
    --secondary-text-color: #6c757d;
    --border-color: #dee2e6;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --border-radius: 12px;
}

html.dark-mode {
    --primary-color: #0a84ff;
    --primary-hover-color: #0060df;
    --danger-color: #ff453a;
    --danger-hover-color: #d9362e;

    --bg-color: #1c1c1e;
    --secondary-bg-color: #2c2c2e;
    --text-color: #f2f2f7;
    --secondary-text-color: #8e8e93;
    --border-color: #3a3a3c;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 700px;
    margin: 40px auto;
    padding: 40px;
    background: var(--secondary-bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    flex-grow: 1;
    transition: background-color 0.3s;
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-color);
    font-weight: 700;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

a:hover {
    color: var(--primary-hover-color);
    text-decoration: underline;
}

hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 30px 0;
}

/* Forms */
form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

label {
    font-weight: 500;
    margin-bottom: -10px;
    color: var(--text-color);
}

.grade-selection {
    display: flex;
    gap: 20px;
    align-items: center;
}

input[type="radio"] {
    accent-color: var(--primary-color);
}

textarea,
input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 16px;
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s, color 0.3s;
}

textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 20%, transparent);
}

textarea {
    height: 150px;
    resize: vertical;
}

textarea::placeholder {
    color: var(--secondary-text-color);
}

/* Buttons */
button, .btn {
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    text-align: center;
    display: inline-block;
    width: 100%;
}

button:hover, .btn:hover {
    transform: translateY(-1px);
}

button[type="submit"], .btn-primary {
    background-color: var(--primary-color);
    color: var(--secondary-bg-color);
}

button[type="submit"]:hover, .btn-primary:hover {
    background-color: var(--primary-hover-color);
}

.btn-danger, .logout-btn {
    background-color: var(--danger-color) !important;
    color: var(--secondary-bg-color) !important;
}

.btn-danger:hover, .logout-btn:hover {
    background-color: var(--danger-hover-color) !important;
}

.admin-login-btn {
    display: block;
    text-align: center;
    margin-top: 20px;
    padding: 12px;
    background-color: var(--text-color);
    color: var(--bg-color);
    border-radius: var(--border-radius);
}
.admin-login-btn:hover {
    opacity: 0.8;
    text-decoration: none;
}

/* Admin Section */
.admin-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.admin-buttons a, .admin-buttons button {
    flex: 1;
    text-decoration: none;
}

/* Messages */
.message {
    margin-top: 20px;
    padding: 15px;
    border-radius: var(--border-radius);
    display: none;
    text-align: center;
    border: 1px solid transparent;
}

.message.error {
    background-color: color-mix(in srgb, var(--danger-color) 15%, transparent);
    color: var(--danger-color);
    border-color: var(--danger-color);
    display: block;
}

.message.success {
    background-color: color-mix(in srgb, var(--primary-color) 15%, transparent);
    color: var(--primary-color);
    border-color: var(--primary-color);
    display: block;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    font-size: 14px;
    color: var(--secondary-text-color);
    width: 100%;
}

/* Dark Mode Toggle */
.theme-switch-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.theme-switch-wrapper span {
    font-size: 12px;
    color: var(--secondary-text-color);
    margin-bottom: 4px;
}

.theme-switch {
    display: inline-block;
    height: 24px;
    position: relative;
    width: 50px;
}
.theme-switch input {
    display:none;
}
.slider {
    background-color: #ccc;
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border-radius: 34px;
}
.slider:before {
    background-color: #fff;
    bottom: 4px;
    content: "";
    height: 16px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 16px;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--primary-color);
}
input:checked + .slider:before {
    transform: translateX(26px);
}

/* Admin Panel Table */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 30px 0;
    box-shadow: var(--shadow);
    border-radius: var(--border-radius);
    overflow: hidden;
    background-color: var(--secondary-bg-color);
}

th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--bg-color);
    font-weight: 700;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background-color: color-mix(in srgb, var(--text-color) 5%, transparent);
}

.checkbox-cell {
    width: 50px;
    text-align: center;
}
.checkbox-cell input {
    width: 18px;
    height: 18px;
}

.content-text {
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

.user-agent {
    font-size: 0.9em;
    color: var(--secondary-text-color);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        margin: 20px;
        padding: 20px;
        width: auto;
    }

    h1 {
        font-size: 24px;
    }

    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead {
        display: none;
    }

    tr {
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        margin-bottom: 15px;
        padding: 15px;
    }

    td {
        padding: 10px 0;
        border: none;
        position: relative;
        padding-left: 100px;
        min-height: 30px;
    }

    td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 90px;
        font-weight: bold;
        white-space: nowrap;
    }

    .checkbox-cell {
        padding-left: 0;
    }
    .checkbox-cell:before {
        display: none;
    }
    .content-cell {
        padding-left: 0;
    }
    .content-cell:before {
        display: block;
        margin-bottom: 10px;
        position: static;
        width: auto;
    }
}