/* ===== 기본 리셋 및 변수 ===== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;
    --shadow: rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ===== 리다이렉트 오버레이 ===== */
.redirect-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--background);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.redirect-overlay.hidden {
    display: none;
}

.redirect-content {
    text-align: center;
}

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

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

.redirect-content p {
    font-size: 1.2rem;
    color: var(--text);
    margin-bottom: 10px;
}

.redirect-content span {
    color: var(--text-muted);
    font-size: 0.9rem;
    word-break: break-all;
}

/* ===== 컨테이너 ===== */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== 헤더 ===== */
.header {
    text-align: center;
    padding: 40px 20px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo i {
    font-size: 2.5rem;
    color: var(--primary);
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* ===== 탭 네비게이션 ===== */
.tab-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    background: var(--surface);
    padding: 8px;
    border-radius: var(--radius);
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--text);
    background: var(--surface-light);
}

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

.tab-btn i {
    font-size: 1rem;
}

/* ===== 탭 컨텐츠 ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== 카드 ===== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px var(--shadow);
}

.card h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.card h2 i {
    color: var(--primary);
}

/* ===== 폼 스타일 ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.form-group label i {
    margin-right: 5px;
    color: var(--primary-light);
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* ===== 버튼 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text);
    width: 100%;
}

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

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: white;
    width: 100%;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(239, 68, 68, 0.4);
}

.btn-copy {
    background: var(--primary);
    color: white;
    padding: 14px 18px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

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

/* ===== 결과 영역 ===== */
.result {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid var(--border);
}

.result.hidden {
    display: none;
}

.result h3 {
    color: var(--success);
    font-size: 1.1rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.result-url {
    display: flex;
    margin-bottom: 15px;
}

.result-url input {
    flex: 1;
    padding: 14px 16px;
    background: var(--background);
    border: 2px solid var(--primary);
    border-right: none;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    color: var(--primary-light);
    font-size: 1rem;
    font-weight: 500;
}

.result-note {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.result-note i {
    color: var(--warning);
}

/* ===== URL 리스트 ===== */
.url-list {
    max-height: 400px;
    overflow-y: auto;
}

.url-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--background);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.url-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 10px var(--shadow);
}

.url-item-info {
    flex: 1;
    min-width: 0;
}

.url-item-code {
    font-weight: 600;
    color: var(--primary-light);
    font-size: 1rem;
    margin-bottom: 4px;
}

.url-item-title {
    color: var(--text);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.url-item-original {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.url-item-stats {
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.url-item-stats i {
    margin-right: 5px;
}

.url-item-go {
    background: var(--primary);
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
}

.url-item-go:hover {
    background: var(--primary-dark);
}

.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 30px;
}

.empty-message {
    text-align: center;
    color: var(--text-muted);
    padding: 30px;
}

/* ===== 관리 섹션 ===== */
.manage-result {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid var(--border);
}

.manage-result.hidden {
    display: none;
}

.url-info {
    background: var(--background);
    padding: 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 25px;
}

.url-info h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--primary-light);
}

.info-grid {
    display: grid;
    gap: 15px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-item .label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.info-item .value {
    color: var(--text);
    font-weight: 500;
}

.info-item .url-value {
    word-break: break-all;
    color: var(--primary-light);
}

.edit-section, .delete-section {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 1px solid var(--border);
}

.edit-section h4, .delete-section h4 {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.delete-section h4 {
    color: var(--danger);
}

/* ===== 에러 메시지 ===== */
.error-message {
    margin-top: 20px;
    padding: 15px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--danger);
    display: flex;
    align-items: center;
    gap: 10px;
}

.error-message.hidden {
    display: none;
}

/* ===== 토스트 ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--success);
    color: white;
    padding: 15px 25px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 5px 20px rgba(16, 185, 129, 0.4);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.hidden {
    display: none;
}

/* ===== 푸터 ===== */
.footer {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== 반응형 ===== */
@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    .header {
        padding: 30px 15px;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .logo i {
        font-size: 2rem;
    }

    .tab-nav {
        flex-direction: column;
        gap: 5px;
    }

    .tab-btn {
        padding: 12px 15px;
    }

    .card {
        padding: 20px;
    }

    .url-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .url-item-stats {
        width: 100%;
        justify-content: space-between;
    }

    .url-item-original {
        max-width: 100%;
    }

    .result-url {
        flex-direction: column;
    }

    .result-url input {
        border-radius: var(--radius-sm) var(--radius-sm) 0 0;
        border-right: 2px solid var(--primary);
        border-bottom: none;
    }

    .btn-copy {
        border-radius: 0 0 var(--radius-sm) var(--radius-sm);
        padding: 12px;
    }
}

/* ===== 스크롤바 ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
