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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --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), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

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

.container { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 24px 0;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
}
.header .container { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.header h1 { font-size: 1.5rem; font-weight: 700; }
.header a { color: white; text-decoration: none; opacity: 0.9; font-size: 0.9rem; }
.header a:hover { opacity: 1; }

/* Cards */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

/* Team Grid (Admin) */
.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 20px;
}
.team-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: var(--gray-900);
    border: 2px solid transparent;
}
.team-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}
.team-card .team-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 1.4rem;
    font-weight: 700;
}
.team-card .team-name { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; }
.team-card .team-stats { font-size: 0.85rem; color: var(--gray-500); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: white; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-outline:hover { background: var(--gray-100); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* Category Tabs */
.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}
.cat-tab {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    transition: all 0.2s;
    white-space: nowrap;
}
.cat-tab:hover { background: var(--gray-200); }
.cat-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.cat-tab .badge {
    background: rgba(255,255,255,0.3);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: 4px;
}
.cat-tab.active .badge { background: rgba(255,255,255,0.3); }

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--gray-50);
    margin-bottom: 20px;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: #eff6ff;
}
.upload-zone .icon { font-size: 3rem; margin-bottom: 12px; color: var(--gray-500); }
.upload-zone p { color: var(--gray-500); margin-bottom: 8px; }
.upload-zone .hint { font-size: 0.8rem; color: var(--gray-500); }

/* Progress */
.upload-progress { margin-bottom: 20px; display: none; }
.upload-progress.active { display: block; }
.progress-bar-wrap {
    background: var(--gray-200);
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #6366f1);
    border-radius: 10px;
    width: 0%;
    transition: width 0.3s;
}
.progress-text { font-size: 0.85rem; color: var(--gray-500); text-align: center; }

/* File Gallery */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.gallery-item {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--gray-100);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
}
.gallery-item:hover { transform: scale(1.02); }
.gallery-item .thumb-wrap {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
}
.gallery-item img, .gallery-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.gallery-item .file-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: white;
    padding: 20px 8px 8px;
    font-size: 0.75rem;
}
.gallery-item .file-info .name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gallery-item .file-type-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
}
.gallery-item .delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(220,38,38,0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.gallery-item:hover .delete-btn { display: flex; }
.thumb-wrap:hover .delete-btn { display: flex; }

/* Video placeholder */
.video-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
    color: white;
    font-size: 3rem;
    width: 100%;
    height: 100%;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.lightbox.active { display: flex; }
.lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius);
}
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    background: none;
    border: none;
    z-index: 10000;
}

/* Login Form */
.login-form {
    max-width: 400px;
    margin: 100px auto;
}
.login-form input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 1rem;
    margin-bottom: 12px;
}
.login-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

/* Form Elements */
select {
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
}
select:focus { outline: none; border-color: var(--primary); }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}
.empty-state .icon { font-size: 4rem; margin-bottom: 12px; opacity: 0.5; }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 10001; }
.toast {
    background: white;
    padding: 14px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    min-width: 250px;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}
.pagination button {
    padding: 8px 14px;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
}
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Responsive */
@media (max-width: 768px) {
    .container { padding: 12px; }
    .header h1 { font-size: 1.2rem; }
    .team-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .team-card { padding: 16px; }
    .gallery { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
    .upload-zone { padding: 24px 12px; }
    .upload-zone .icon { font-size: 2rem; }
    .category-tabs { gap: 6px; }
    .cat-tab { padding: 6px 12px; font-size: 0.8rem; }
}

@media (max-width: 480px) {
    .team-grid { grid-template-columns: repeat(2, 1fr); }
    .gallery { grid-template-columns: repeat(2, 1fr); }
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Section title */
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--gray-700);
}

/* Flex utilities */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mb-12 { margin-bottom: 12px; }
.mb-20 { margin-bottom: 20px; }
.text-center { text-align: center; }

/* File URL Bar (always visible under image for admin) */
.file-url-bar {
    display: flex;
    background: var(--gray-100);
    padding: 4px;
    gap: 4px;
    border-top: 1px solid var(--gray-200);
}
.file-url-bar input {
    flex: 1;
    min-width: 0;
    padding: 4px 6px;
    font-size: 0.65rem;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    background: white;
    color: var(--gray-700);
    outline: none;
}
.file-url-bar input:focus { border-color: var(--primary); }
.file-url-bar button {
    padding: 4px 8px;
    font-size: 0.65rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    font-weight: 600;
}
.file-url-bar button:hover { background: var(--primary-dark); }

/* Copy URL button on gallery item */
.copy-url-btn {
    position: absolute;
    top: 8px;
    right: 38px;
    background: rgba(37,99,235,0.85);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    z-index: 3;
}
.gallery-item:hover .copy-url-btn, .thumb-wrap:hover .copy-url-btn { display: flex; }

/* Lightbox URL bar */
.lightbox-url {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    max-width: 90vw;
    width: 600px;
}
.lightbox-url input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    font-size: 0.85rem;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    outline: none;
}
.lightbox-url button {
    padding: 8px 16px;
    font-size: 0.85rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}
.lightbox-url button:hover { background: var(--primary-dark); }
#lightbox-body {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Select checkbox on gallery items */
.select-check {
    position: absolute;
    bottom: 8px;
    left: 8px;
    z-index: 6;
    cursor: pointer;
}
.select-check input { display: none; }
.select-check span {
    display: block;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    border: 2px solid rgba(255,255,255,0.7);
    background: rgba(0,0,0,0.3);
    transition: all 0.15s;
}
.select-check input:checked + span {
    background: var(--primary);
    border-color: var(--primary);
}
.select-check input:checked + span::after {
    content: '';
    display: block;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin: 2px auto 0;
}
.gallery-item.selected { outline: 3px solid var(--primary); outline-offset: -3px; }

/* Bulk URL copy bar */
.bulk-url-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--gray-900);
    color: white;
    padding: 14px 24px;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 9998;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
}
.bulk-url-bar button {
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    background: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
}
.bulk-url-bar button:hover { opacity: 0.9; }

/* Comment button on gallery items */
.comment-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(37,99,235,0.85);
    color: white;
    border: none;
    border-radius: 12px;
    min-width: 26px;
    height: 24px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 700;
    z-index: 6;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.comment-btn:hover { background: rgba(37,99,235,1); transform: scale(1.1); }

/* Move category button */
.move-cat-btn {
    position: absolute;
    bottom: 8px;
    right: 40px;
    background: rgba(16,185,129,0.85);
    color: white;
    border: none;
    border-radius: 12px;
    min-width: 26px;
    height: 24px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    z-index: 6;
    padding: 0 6px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.gallery-item:hover .move-cat-btn, .thumb-wrap:hover .move-cat-btn { display: flex; }
.move-cat-btn:hover { background: rgba(16,185,129,1); transform: scale(1.1); }

/* Usage button */
.usage-btn {
    position: absolute;
    bottom: 34px;
    right: 8px;
    background: rgba(245,158,11,0.85);
    color: white;
    border: none;
    border-radius: 12px;
    min-width: 26px;
    height: 24px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 700;
    z-index: 6;
    padding: 0 6px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.gallery-item:hover .usage-btn, .thumb-wrap:hover .usage-btn { display: flex; }
.usage-btn:hover { background: rgba(245,158,11,1); transform: scale(1.1); }

/* Batch group header */
.batch-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: linear-gradient(90deg, #eff6ff, #f8fafc);
    border: 1px solid #dbeafe;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    margin-top: 8px;
}
.batch-header:first-child { margin-top: 0; }
.batch-header .batch-time { font-weight: 400; color: var(--gray-400); font-size: 0.75rem; }
