/*
 * KUHWA Portal 스타일시트
 *
 * 참조 소스:
 * - Tailwind CSS 색상 토큰: https://tailwindcss.com (blue-500, red-500, emerald-500 등)
 * - 커스텀 CSS 변수 시스템: Tailwind의 디자인 토큰을 CSS 변수로 변환
 * - 폰트 스택: Tailwind 기본 폰트 시스템
 */

/* Base Styles */
:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.nav-brand a {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
    text-decoration: none;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    color: var(--gray-700);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: background 0.2s;
}

.nav-link:hover {
    background: var(--gray-100);
}

.nav-user {
    color: var(--gray-500);
    padding: 0.5rem 1rem;
}

.nav-form {
    display: inline;
}

/* Container */
.container {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

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

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

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

.btn-outline {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-outline:hover {
    background: var(--gray-50);
}

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

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

.btn-block {
    width: 100%;
}

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

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

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

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

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* Google Login Button */
.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-google:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

/* Auth Divider */
.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--gray-500);
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--gray-300);
}

.auth-divider span {
    padding: 0 1rem;
    font-size: 0.875rem;
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
}

.auth-card {
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.auth-title {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--gray-900);
}

.auth-form {
    margin-bottom: 1.5rem;
}

.auth-footer {
    text-align: center;
    color: var(--gray-500);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
}

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

/* Upload Page */
.upload-container {
    max-width: 800px;
    margin: 0 auto;
}

.upload-card {
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    margin-bottom: 2rem;
}

.upload-title {
    text-align: center;
    margin-bottom: 0.5rem;
}

.upload-subtitle {
    text-align: center;
    color: var(--gray-500);
    margin-bottom: 2rem;
}

.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 1.5rem;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.upload-icon {
    color: var(--gray-400);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.125rem;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.upload-hint {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.file-name {
    flex: 1;
    font-weight: 500;
    word-break: break-all;
}

.file-size {
    color: var(--gray-500);
}

/* Recent Conversions */
.recent-card {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.recent-card h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.recent-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.recent-filename {
    font-weight: 500;
}

.recent-date {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.recent-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--gray-200);
    color: var(--gray-700);
}

.status-badge.success {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.warning {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.danger {
    background: #fee2e2;
    color: #991b1b;
}

/* Convert Page */
.convert-container {
    max-width: 600px;
    margin: 0 auto;
}

.convert-card {
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.convert-title {
    margin-bottom: 2rem;
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 2rem;
}

.file-icon {
    color: var(--danger);
}

.file-details {
    flex: 1;
}

.file-details .file-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.file-details .file-size,
.file-details .file-info {
    font-size: 0.875rem;
    color: var(--gray-500);
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.form-actions .btn {
    flex: 1;
}

/* Download Page */
.download-container {
    max-width: 600px;
    margin: 0 auto;
}

.download-card {
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.success-icon {
    color: var(--success);
    margin-bottom: 1rem;
}

.error-icon {
    color: var(--danger);
    margin-bottom: 1rem;
}

.loading-icon {
    margin-bottom: 1rem;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.download-title {
    margin-bottom: 0.5rem;
}

.download-subtitle {
    color: var(--gray-500);
    margin-bottom: 2rem;
}

.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 60%;
    animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 30%; }
    50% { width: 70%; }
    100% { width: 30%; }
}

.download-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* History Page */
.history-container {
    max-width: 1000px;
    margin: 0 auto;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.history-title {
    font-size: 1.5rem;
}

.history-table-wrapper {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.history-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
}

.history-table tbody tr:hover {
    background: var(--gray-50);
}

.history-table .filename {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-table .actions {
    display: flex;
    gap: 0.5rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.empty-state svg {
    color: var(--gray-400);
    margin-bottom: 1rem;
}

.empty-state h2 {
    margin-bottom: 0.5rem;
    color: var(--gray-700);
}

.empty-state p {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--gray-500);
    font-size: 0.875rem;
    border-top: 1px solid var(--gray-200);
    background: white;
}

/* Upload Options */
.upload-options {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.option-item {
    flex: 1;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 2px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
}

.option-item:hover {
    border-color: var(--gray-300);
}

.option-item:has(input:checked) {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

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

.option-item input[type="radio"] {
    margin-right: 0.5rem;
}

.option-item label {
    font-weight: 500;
    cursor: pointer;
}

.option-desc {
    display: block;
    font-size: 0.8125rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
    margin-left: 1.5rem;
}

/* File List in Upload */
.file-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 0.5rem;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.file-icon-small {
    color: var(--danger);
    flex-shrink: 0;
}

.file-item .file-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.875rem;
    word-break: break-all;
}

.file-item .file-size {
    color: var(--gray-500);
    font-size: 0.8125rem;
    flex-shrink: 0;
}

.file-item .remove-btn {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.25rem;
    flex-shrink: 0;
    transition: color 0.2s;
}

.file-item .remove-btn:hover {
    color: var(--danger);
}

.file-summary {
    text-align: center;
    padding: 0.5rem;
    background: var(--gray-100);
    border-radius: var(--radius);
}

.summary-text {
    font-size: 0.875rem;
    color: var(--gray-700);
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    
    .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .container {
        padding: 1rem;
    }
    
    .upload-card,
    .convert-card,
    .download-card {
        padding: 1.5rem;
    }
    
    .upload-title,
    .convert-title,
    .download-title {
        font-size: 1.25rem;
    }
    
    .upload-zone {
        padding: 2rem;
    }
    
    .upload-icon svg {
        width: 48px;
        height: 48px;
    }
    
    .upload-options {
        flex-direction: column;
    }
    
    .option-item {
        padding: 0.875rem;
    }
    
    .form-group input,
    .form-group select {
        padding: 0.625rem 0.875rem;
        font-size: 16px;
    }
    
    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.9375rem;
    }
    
    .btn-large {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    .download-actions {
        flex-direction: column;
    }
    
    .download-actions .btn {
        width: 100%;
    }
    
    .file-preview {
        flex-direction: column;
        text-align: center;
    }
    
    .history-table {
        font-size: 0.8125rem;
    }
    
    .history-table th,
    .history-table td {
        padding: 0.625rem 0.375rem;
    }
    
    .history-table .actions {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .history-table .actions .btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .auth-card {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    .recent-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .recent-status {
        width: 100%;
        justify-content: space-between;
    }
    
    .footer {
        padding: 1rem;
        font-size: 0.8125rem;
    }
    
    .file-info {
        flex-direction: column;
    }
}

/* Small phones */
@media (max-width: 400px) {
    .navbar {
        padding: 0.75rem;
    }
    
    .nav-brand a {
        font-size: 1.25rem;
    }
    
    .container {
        padding: 0.75rem;
    }
    
    .upload-card,
    .convert-card,
    .download-card {
        padding: 1.25rem;
    }
    
    .upload-zone {
        padding: 1.5rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
    }
    
    .file-info {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .file-name {
        width: 100%;
    }
    
    .file-size {
        width: 100%;
    }
}

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .form-group input,
    .form-group select {
        min-height: 44px;
    }
    
    .upload-zone {
        min-height: 200px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --gray-50: #1f2937;
        --gray-100: #374151;
        --gray-200: #4b5563;
        --gray-300: #6b7280;
        --gray-500: #9ca3af;
        --gray-700: #d1d5db;
        --gray-900: #f9fafb;
    }
    
    body {
        background-color: #111827;
    }
    
    .navbar,
    .auth-card,
    .upload-card,
    .convert-card,
    .download-card,
    .recent-card,
    .history-table-wrapper,
    .empty-state {
        background-color: #1f2937;
    }
    
    .footer {
        background-color: #1f2937;
        border-top-color: #374151;
    }
}

/* Print styles */
@media print {
    .navbar,
    .footer,
    .btn,
    .alert {
        display: none !important;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
    
    .download-card,
    .convert-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
