﻿/* --- Variables & Base Styles --- */
:root {
    --c-bg: #E2E9FA;
    --c-card: #FFFFFF;
    --c-primary: #6c93f0;
    --c-hover: #b9cdef;
    --c-active: #5270B5;
    --c-text-neutral: #545D70;
    --c-text-dark: #0C1829;
    --c-text-main: #0C1829;
    /* Alias for compatibility */
    --primary-blue: #6c93f0;
    /* Alias for compatibility */
    --c-secondary: #64748b;
    /* Fallback for secondary text */
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Pretendard', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--c-bg);
    color: var(--c-text-main);
    line-height: 1.5;
}

/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10002;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    animation: modal-in 0.2s ease-out;
}

@keyframes modal-in {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Pagination Styles */
.page-btn {
    padding: 8px 14px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #64748b;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    min-width: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.page-btn:hover:not(:disabled) {
    border-color: var(--c-primary);
    color: var(--c-primary);
    background: #f8fbff;
}

.page-btn.active {
    background: var(--c-primary);
    color: white;
    border-color: var(--c-primary);
    box-shadow: 0 4px 6px rgba(108, 147, 240, 0.2);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f8fafc;
}

/* --- Toast Notification System --- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    min-width: 300px;
    max-width: 450px;
    background: white;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: toast-in 0.3s ease-out forwards;
    border-left: 5px solid #cbd5e1;
}

.toast.toast-out {
    animation: toast-out 0.3s ease-in forwards;
}

.toast-success {
    border-left-color: #10b981;
}

.toast-error {
    border-left-color: #ef4444;
}

.toast-info {
    border-left-color: var(--c-primary);
}

@keyframes toast-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toast-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* --- Skeleton Loader UI --- */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite linear;
    border-radius: 4px;
}

@keyframes skeleton-shimmer {
    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
    width: 100%;
}

.skeleton-title {
    height: 2rem;
    margin-bottom: 1rem;
    width: 60%;
}

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

.skeleton-table th,
.skeleton-table td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.skeleton-cell {
    height: 1.25rem;
    background-color: #f1f5f9;
    border-radius: 4px;
}

/* --- Layout & Grid Fixes (Desktop/General) --- */
.text-input,
select.text-input {
    height: 44px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
}

.btn-primary {
    height: 44px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 1.5rem;
    white-space: nowrap;
}

/* Input group with buttons (like link copy) */
.input-group div[style*="display:flex"],
.input-group div[style*="display: flex"] {
    gap: 0.5rem;
    align-items: stretch;
    /* Ensure same height */
}

/* 모바일 grid-template-columns 강제 오버라이드 대비용 Utility */
.mobile-grid-1col {
    grid-template-columns: 1fr !important;
}

/* 📱 모바일 대응 (반응형 Card View) */
@media (max-width: 768px) {

    /* 레이아웃 & 사이드바 Overrides */
    .main-sidebar {
        width: 100% !important;
        height: auto !important;
        position: relative !important;
        padding-top: 1rem !important;
    }

    .main-sidebar h1 {
        margin-bottom: 1rem !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 5rem 1rem 1rem 1rem !important;
        /* Hamburger menu space */
    }

    /* 카드 및 여백 최적화 */
    .card {
        padding: 1.25rem !important;
        margin-bottom: 1rem;
    }

    .input-group {
        margin-bottom: 1rem;
    }

    /* 그리드 시스템 해제 (1열 배치) */
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* 입력 필드 제목 잘림 방지 */
    .input-label {
        white-space: normal !important;
        overflow: visible !important;
    }

    /* 탭 메뉴 줄바꿈 허용 */
    .sub-tabs,
    .tab-container {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    .tab-btn {
        flex: 1;
        text-align: center;
        min-width: 80px;
    }

    /* --- List Table to Card View Transformation --- */
    .list-table {
        display: block !important;
        width: 100% !important;
        border: none !important;
    }

    .list-table thead {
        display: none !important;
    }

    .list-table tbody,
    .list-table tr,
    .list-table td {
        display: block !important;
        width: 100% !important;
    }

    .list-table tr {
        background: #fff !important;
        margin-bottom: 1rem !important;
        padding: 0 !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 12px !important;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05) !important;
        overflow: hidden;
    }

    .list-table td {
        text-align: right !important;
        padding: 0.75rem 1rem 0.75rem 30% !important;
        /* Label space */
        border-bottom: 1px solid #f1f5f9 !important;
        position: relative !important;
        font-size: 0.95rem !important;
        min-height: 3rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
    }

    .list-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        top: 50%;
        transform: translateY(-50%);
        font-weight: 600;
        color: #64748b;
        font-size: 0.85rem;
        text-transform: capitalize;
        width: 25%;
        text-align: left;
    }

    /* Last cell (Action) */
    .list-table td:last-child {
        border-bottom: none !important;
        background: #f8fafc !important;
        padding: 0.75rem 1rem !important;
        justify-content: flex-end !important;
        gap: 0.5rem;
    }

    .list-table td:last-child::before {
        display: none;
    }

    /* Button Optimization */
    .list-table td:last-child button {
        padding: 0.6rem 1rem !important;
        font-size: 0.9rem !important;
        width: auto !important;
        min-width: 60px;
    }
}

/* 📱 사이드바 모바일 대응 */
@media (max-width: 768px) {
    #mobile-menu-toggle {
        display: flex !important;
    }

    .sidebar {
        position: fixed !important;
        left: -260px !important;
        top: 0 !important;
        height: 100vh !important;
        z-index: 1000 !important;
        transition: left 0.3s ease !important;
        box-shadow: 10px 0 15px rgba(0, 0, 0, 0.1) !important;
    }

    .sidebar.active {
        left: 0 !important;
    }

    .mobile-only {
        display: block !important;
    }
}