/* ========================================
   Korean Fiction Temporal Annotation System
   CSS Stylesheet
   ======================================== */

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

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* ========== Layout ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.labeling-container {
    max-width: 1400px;
}

/* ========== Header ========== */
header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 1.5rem 0;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

header .subtitle {
    opacity: 0.9;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-link {
    color: white;
    text-decoration: none;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.back-link:hover {
    opacity: 1;
}

.header-info {
    display: flex;
    gap: 2rem;
    font-size: 0.9rem;
    opacity: 0.9;
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

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

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-tiny {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== Forms ========== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-group.required label::after {
    content: ' *';
    color: var(--danger-color);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="email"],
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
    margin-bottom: 1rem;
}

.form-row.two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
}

.inline-form {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.inline-form input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
}

/* ========== Login Page ========== */
.login-container {
    max-width: 400px;
    margin: 4rem auto;
}

.login-box {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.login-box h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.login-box .btn {
    width: 100%;
    margin-top: 1rem;
}

.error-message {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    text-align: center;
}

.divider {
    display: flex;
    align-items: center;
    margin: 2rem 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.divider span {
    padding: 0 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.admin-link {
    text-align: center;
}

.admin-link .btn {
    width: 100%;
}

/* ========== Dashboard ========== */
.progress-section,
.documents-section,
.guide-section {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.progress-section h2,
.documents-section h2,
.guide-section h2 {
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
}

.overall-progress {
    margin-bottom: 1.5rem;
}

.progress-bar-container {
    background: var(--border-color);
    border-radius: 999px;
    height: 1.5rem;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    height: 100%;
    border-radius: 999px;
    transition: width 0.3s ease;
}

.progress-stats {
    text-align: center;
    font-size: 1.125rem;
    color: var(--text-muted);
}

/* ========== Document Cards ========== */
.documents-list {
    display: grid;
    gap: 1rem;
}

.document-card {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-color);
    border-radius: var(--radius);
    border-left: 4px solid var(--primary-color);
}

.document-card.completed {
    border-left-color: var(--success-color);
    background: #f0fdf4;
}

.doc-info .doc-id {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--border-color);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
}

.doc-info .doc-title {
    font-size: 1rem;
    margin: 0.25rem 0;
}

.doc-info .doc-author {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.doc-progress {
    text-align: right;
}

.mini-progress-bar {
    width: 100px;
    height: 6px;
    background: var(--border-color);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.mini-progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 999px;
}

.doc-stats {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ========== Guide ========== */
.guide-content {
    display: grid;
    gap: 1rem;
}

.guide-item {
    padding: 1rem;
    background: var(--bg-color);
    border-radius: var(--radius);
    border-left: 3px solid var(--primary-color);
}

.guide-item h3 {
    font-size: 0.9rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.guide-item p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ========== Labeling Page ========== */
.labeling-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem 2rem;
}

.completion-message {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.completion-message h2 {
    color: var(--success-color);
    margin-bottom: 1rem;
}

.completion-message p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.metadata-panel {
    display: flex;
    gap: 2rem;
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.meta-item {
    display: flex;
    flex-direction: column;
}

.meta-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.meta-value {
    font-weight: 600;
}

.text-panel {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.text-panel h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.segment-text {
    padding: 1.5rem;
    background: #fefce8;
    border-radius: var(--radius);
    border-left: 4px solid var(--warning-color);
    font-size: 1.125rem;
    line-height: 1.8;
    max-height: 400px;
    overflow-y: auto;
}

.segment-text p {
    margin: 0;
    word-break: keep-all;
}

.text-stats {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.labeling-form-panel {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    color: white;
    border-radius: 50%;
    font-size: 0.7rem;
    cursor: help;
    margin-left: 0.25rem;
}

.navigation-panel {
    background: var(--card-bg);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.navigation-panel h4 {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.segment-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.nav-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: white;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--bg-color);
}

.nav-btn.current {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.nav-btn.completed {
    background: #d1fae5;
    border-color: var(--success-color);
    color: var(--success-color);
}

.nav-btn.completed.current {
    background: var(--success-color);
    color: white;
}

/* ========== Admin Page ========== */
.admin-login-section {
    max-width: 400px;
    margin: 4rem auto;
}

.admin-section {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.admin-section h2 {
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
}

.admin-section h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.add-labeler-form {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

/* ========== Tables ========== */
table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    background: var(--bg-color);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.key-code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.75rem;
    background: var(--bg-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    word-break: break-all;
}

/* ========== Import ========== */
.import-json-form {
    margin-bottom: 1rem;
}

.help-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.import-result {
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 1rem;
}

.import-result.success {
    background: #d1fae5;
    color: #065f46;
}

.import-result.error {
    background: #fee2e2;
    color: #991b1b;
}

/* ========== Progress Grid ========== */
.progress-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.progress-card {
    padding: 1.5rem;
    background: var(--bg-color);
    border-radius: var(--radius);
    text-align: center;
}

.progress-card h4 {
    margin-bottom: 1rem;
}

.progress-card p {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ========== Utility ========== */
.loading {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 2rem;
}

.no-data {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

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

/* ========== Footer ========== */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .header-info {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .metadata-panel {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .form-row.two-columns {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column-reverse;
    }
    
    .document-card {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .doc-progress {
        text-align: center;
    }
    
    .mini-progress-bar {
        margin: 0 auto;
    }
    
    table {
        display: block;
        overflow-x: auto;
    }
    
    .inline-form {
        flex-direction: column;
    }
}
