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

/* ═══════════════════════════════════════════════
 *  RESET
 * ═══════════════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ═══════════════════════════════════════════════
 *  DESIGN TOKENS
 * ═══════════════════════════════════════════════ */
:root {
    /* Primary Colors */
    --primary: #2196F3;
    --primary-dark: #1976D2;
    --primary-light: #BBDEFB;
    --primary-bg: #E3F2FD;

    /* Secondary / Functional Colors */
    --success: #4CAF50;
    --success-dark: #388E3C;
    --warning: #FFC107;
    --warning-dark: #FFA000;
    --danger: #F44336;
    --danger-dark: #D32F2F;

    /* Neutral Colors */
    --gray-50: #FAFAFA;
    --gray-100: #F5F5F5;
    --gray-200: #EEEEEE;
    --gray-300: #E0E0E0;
    --gray-400: #BDBDBD;
    --gray-500: #9E9E9E;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;
    --white: #FFFFFF;

    /* Shadows */
    --shadow: rgba(0,0,0,0.1);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Typography */
    --font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --text-xs: 0.75rem;    /* 12px */
    --text-sm: 0.875rem;   /* 14px */
    --text-base: 1rem;     /* 16px */
    --text-lg: 1.125rem;   /* 18px */
    --text-xl: 1.5rem;     /* 24px */
    --text-2xl: 2rem;      /* 32px */
    --font-normal: 400;
    --font-medium: 500;
    --font-bold: 700;

    /* Spacing */
    --space-xs: 0.25rem;   /* 4px */
    --space-sm: 0.5rem;    /* 8px */
    --space-md: 1rem;      /* 16px */
    --space-lg: 1.5rem;    /* 24px */
    --space-xl: 2rem;      /* 32px */

    /* Layout */
    --header-height: 64px;
    --max-width: 1200px;
    --transition: all 0.3s ease;

    /* Focus */
    --focus-ring: 0 0 0 2px var(--primary);
    --focus-ring-offset: 0 0 0 2px var(--white), 0 0 0 4px var(--primary);
}

/* ═══════════════════════════════════════════════
 *  BASE
 * ═══════════════════════════════════════════════ */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: var(--text-base);
    font-weight: var(--font-normal);
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
    color: var(--primary-dark);
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    background: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: var(--text-sm);
}

/* Remove default outline — replaced by custom focus styles */
:focus {
    outline: none;
}

/* ═══════════════════════════════════════════════
 *  ACCESSIBILITY — Focus Visible
 * ═══════════════════════════════════════════════ */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    box-shadow: var(--focus-ring-offset);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

/* Skip to content */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 10000;
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: var(--white);
    border-radius: var(--radius-sm);
    font-weight: var(--font-medium);
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0.5rem;
    color: var(--white);
}

/* ═══════════════════════════════════════════════
 *  HEADER — 64px
 * ═══════════════════════════════════════════════ */
.header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-300);
    padding: 0 1.5rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo {
    font-size: 1.25rem;
    font-weight: var(--font-bold);
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-logo svg {
    flex-shrink: 0;
}

.header-nav {
    display: flex;
    gap: 0.25rem;
}

.header-nav a,
.header-nav button {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--gray-600);
    background: transparent;
    transition: var(--transition);
}

.header-nav a:hover,
.header-nav button:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.header-nav a.active,
.header-nav button.active {
    background: var(--primary-bg);
    color: var(--primary);
}

.header-nav a.disabled {
    color: var(--gray-400);
    pointer-events: none;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ═══════════════════════════════════════════════
 *  BUTTONS
 * ═══════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}

/* Primary Button */
.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(33,150,243,0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Secondary / Outline Button */
.btn-outline,
.btn-secondary {
    background: var(--white);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline:hover,
.btn-secondary:hover {
    background: var(--primary-bg);
}

/* Danger Button */
.btn-danger {
    background: var(--danger);
    color: var(--white);
    padding: 0.625rem 1.25rem;
}

.btn-danger:hover {
    background: var(--danger-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(244,67,54,0.3);
}

.btn-danger:active {
    transform: translateY(0);
}

/* Success Button */
.btn-success {
    background: var(--success);
    color: var(--white);
}

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

/* Warning Button */
.btn-warning {
    background: var(--warning);
    color: var(--gray-900);
}

/* Small Button */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* Disabled */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ═══════════════════════════════════════════════
 *  CARDS
 * ═══════════════════════════════════════════════ */
.card {
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 1.25rem;
    transition: var(--transition);
}

.card:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
}

/* ═══════════════════════════════════════════════
 *  FORM ELEMENTS
 * ═══════════════════════════════════════════════ */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--gray-700);
    margin-bottom: 0.375rem;
}

.form-control {
    width: 100%;
    height: 44px;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    transition: var(--transition);
    background: var(--white);
    color: var(--gray-900);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.form-control::placeholder {
    color: var(--gray-400);
}

textarea.form-control {
    height: auto;
    resize: vertical;
    min-height: 80px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    cursor: pointer;
}

/* ═══════════════════════════════════════════════
 *  BADGE
 * ═══════════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
}

.badge-active {
    background: #E8F5E9;
    color: #2E7D32;
}

.badge-inactive {
    background: #FFEBEE;
    color: #C62828;
}

.badge-category {
    background: var(--primary-bg);
    color: var(--primary-dark);
}

/* ═══════════════════════════════════════════════
 *  MODAL — fade in + slide up
 * ═══════════════════════════════════════════════ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
    animation: modalOverlayIn 0.3s ease forwards;
}

@keyframes modalOverlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px);
    opacity: 0;
    animation: modalSlideIn 0.3s ease 0.05s forwards;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
    font-size: var(--text-lg);
    font-weight: 600;
}

.modal-close {
    font-size: 1.5rem;
    color: var(--gray-500);
    padding: 0.25rem;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--gray-900);
    background: var(--gray-100);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-200);
}

/* ═══════════════════════════════════════════════
 *  TABLE
 * ═══════════════════════════════════════════════ */
.table-wrap {
    overflow-x: auto;
}

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

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

table th {
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-50);
    white-space: nowrap;
}

table tr:hover td {
    background: var(--gray-50);
}

/* ═══════════════════════════════════════════════
 *  PAGINATION
 * ═══════════════════════════════════════════════ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 1rem 0;
}

.pagination button {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    transition: var(--transition);
}

.pagination button:hover:not(:disabled) {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
}

.pagination button.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

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

/* ═══════════════════════════════════════════════
 *  SCREEN READER ONLY
 * ═══════════════════════════════════════════════ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ═══════════════════════════════════════════════
 *  RESPONSIVE
 * ═══════════════════════════════════════════════ */

/* Mobile */
@media (max-width: 767px) {
    .header {
        padding: 0 1.25rem;
        height: 56px;
    }

    .header-logo span {
        display: none;
    }

    .header-nav a,
    .header-nav button {
        padding: 0.4rem 0.75rem;
        font-size: 0.8125rem;
    }

    .card {
        padding: 1rem;
    }

    .card:hover {
        transform: none;
    }

    .btn {
        padding: 0.625rem 1rem;
    }

    .modal {
        width: 95%;
        max-height: 85vh;
    }
}

/* Tablet */
@media (min-width: 768px) {
    :root {
        --header-height: 64px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .header {
        padding: 0 2.5rem;
    }
}

/* Large screens */
@media (min-width: 1440px) {
    .header {
        padding: 0 3rem;
    }
}

/* ═══════════════════════════════════════════════
 *  FOOTER
 * ═══════════════════════════════════════════════ */
.site-footer {
    border-top: 1px solid var(--gray-300);
    background: var(--white);
    padding: 2rem 1.5rem;
    margin-top: auto;
    text-align: center;
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.5rem;
}

.footer-links a {
    font-size: var(--text-sm);
    color: var(--primary);
    font-weight: var(--font-medium);
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.footer-copyright {
    font-size: var(--text-xs);
    color: var(--gray-500);
}

.footer-contact {
    font-size: var(--text-xs);
    color: var(--gray-500);
}

.footer-contact a {
    color: var(--gray-600);
    font-weight: var(--font-medium);
}

.footer-contact a:hover {
    color: var(--primary);
}

@media (max-width: 767px) {
    .site-footer {
        padding: 1.5rem 1rem;
    }

    .footer-links {
        gap: 0.4rem 1rem;
    }
}

/* ═══════════════════════════════════════════════
 *  REDUCED MOTION
 * ═══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
