/**
 * NanoBanana - Custom Styles
 * Note: Tailwind CDN doesn't support @apply, so using plain CSS
 */

/* Base Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Content Container */
.content-container {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
}

/* Buttons */
.btn-primary {
    background-color: #f59e0b;
    color: white;
    font-weight: 500;
    padding: 0.5rem 1.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
    border: none;
    cursor: pointer;
}

.btn-primary:hover {
    background-color: #d97706;
}

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

.btn-secondary {
    background-color: #f3f4f6;
    color: #374151;
    font-weight: 500;
    padding: 0.5rem 1.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s;
    border: none;
    cursor: pointer;
}

.btn-secondary:hover {
    background-color: #e5e7eb;
}

/* Dropzone */
.dropzone {
    border: 2px dashed #d1d5db;
    border-radius: 0.75rem;
    padding: 2rem;
    transition: all 0.2s;
    cursor: pointer;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: #fbbf24;
    background-color: #fffbeb;
}

.dropzone.has-file {
    border-color: #f59e0b;
    background-color: #fffbeb;
    padding: 0;
    position: relative;
    overflow: hidden;
}

/* Dropzone 미리보기 컨테이너 */
.dropzone #previewContainer {
    width: 100%;
    position: relative;
}

.dropzone #previewContainer img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    display: block;
    background-color: #f9fafb;
}

.dropzone #previewContainer #fileName {
    padding: 0.5rem;
    text-align: center;
    font-size: 0.875rem;
    color: #6b7280;
    background-color: #fffbeb;
    margin: 0;
}

/* 호버 오버레이 */
.dropzone-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.dropzone.has-file:hover .dropzone-overlay {
    opacity: 1;
}

.dropzone-overlay svg {
    width: 2rem;
    height: 2rem;
    margin-bottom: 0.5rem;
}

.dropzone-overlay span {
    font-size: 0.875rem;
    font-weight: 500;
}

/* 삭제 버튼 */
.dropzone #removeImageBtn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 10;
    background-color: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 9999px;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dropzone #removeImageBtn:hover {
    background-color: #dc2626;
}

/* Popup Overlay */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.popup-overlay.hidden {
    display: none !important;
}

.popup-content {
    background-color: white;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 1.5rem;
    max-height: 90vh;
    overflow-y: auto;
    animation: popupIn 0.2s ease-out;
}

@keyframes popupIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Progress Bar */
.progress-bar-container {
    width: 100%;
    height: 1rem;
    background-color: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, #fbbf24, #f59e0b);
    border-radius: 9999px;
    transition: width 0.3s ease;
    background-size: 200% 100%;
    animation: progressShimmer 2s infinite linear;
}

@keyframes progressShimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Image Grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.image-grid-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 0.5rem;
    overflow: hidden;
    background-color: #f3f4f6;
    cursor: pointer;
}

.image-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.image-grid-item:hover img {
    transform: scale(1.05);
}

.image-grid-item .overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: transparent;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-grid-item:hover .overlay {
    background-color: rgba(0, 0, 0, 0.2);
}

.image-grid-item .stage-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    padding: 0.5rem;
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
}

.image-grid-item .download-btn {
    opacity: 0;
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: rgba(255, 255, 255, 0.9);
    color: #374151;
    padding: 0.375rem;
    border-radius: 9999px;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    border: none;
    cursor: pointer;
}

.image-grid-item:hover .download-btn {
    opacity: 1;
}

.image-grid-item .download-btn:hover {
    background-color: white;
}

/* List Item Card */
.list-item-card {
    background-color: white;
    border-radius: 0.75rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
    padding: 1rem;
    transition: box-shadow 0.2s;
}

.list-item-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.list-item-card .mini-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.125rem;
    width: 6rem;
    height: 6rem;
    border-radius: 0.5rem;
    overflow: hidden;
    flex-shrink: 0;
}

.list-item-card .mini-grid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.pending {
    background-color: #f3f4f6;
    color: #1f2937;
}

.status-badge.processing {
    background-color: #dbeafe;
    color: #1e40af;
}

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

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

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Fade animations */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

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

/* Responsive adjustments */
@media (max-width: 640px) {
    .popup-content {
        margin: 0.5rem;
        padding: 1rem;
    }

    .list-item-card {
        padding: 0.75rem;
    }

    .list-item-card .mini-grid {
        width: 5rem;
        height: 5rem;
    }
}

/* Scrollbar styling for popups */
.popup-content::-webkit-scrollbar {
    width: 6px;
}

.popup-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.popup-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.popup-content::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* ========================================
   App Layout - Sidebar & Topbar
   ======================================== */

/* App Layout Container */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background-color: #1f2937;
    color: #f9fafb;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 40;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #374151;
}

.sidebar-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fbbf24;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-section {
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.nav-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #f9fafb;
    padding: 0.5rem 0.75rem;
    letter-spacing: 0.02em;
}

/* 섹션 타이틀 아이콘 (흰색, 큰 사이즈) */
.nav-section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-section-icon .section-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: #f9fafb;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    color: #d1d5db;
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.15s ease;
}

.nav-link:hover {
    background-color: #374151;
    color: #f9fafb;
}

.nav-link.active {
    background-color: #f59e0b;
    color: #1f2937;
    font-weight: 500;
}

.nav-link.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* 메뉴 항목 아이콘 (회색, 작은 사이즈) */
.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    margin-left: 0.25rem;
}

.nav-icon .menu-icon {
    width: 1rem;
    height: 1rem;
    color: #9ca3af;
}

.nav-link:hover .nav-icon .menu-icon {
    color: #d1d5db;
}

.nav-link.active .nav-icon .menu-icon {
    color: #1f2937;
}

/* 단일 항목 메뉴 (포인트 관리) */
.nav-link-single {
    font-weight: 500;
}

.nav-link-single .nav-section-icon .section-icon {
    width: 1.125rem;
    height: 1.125rem;
}

.nav-divider {
    height: 1px;
    background-color: #374151;
    margin: 0.75rem 1rem;
}

/* Main Wrapper */
.main-wrapper {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: #f9fafb;
}

/* Topbar */
.topbar {
    height: 56px;
    background-color: white;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
}

.topbar-container {
    width: 100%;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.sidebar-toggle {
    display: none;
    padding: 0.5rem;
    border-radius: 0.375rem;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #374151;
}

.sidebar-toggle:hover {
    background-color: #f3f4f6;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #6b7280;
}

.breadcrumb .current-page {
    color: #111827;
    font-weight: 500;
}

.breadcrumb .separator {
    color: #d1d5db;
}

/* Points Display */
.points-display {
    font-weight: 600;
    color: #f59e0b;
}

.profile-link {
    color: #6b7280;
    text-decoration: none;
    transition: color 0.15s;
}

.profile-link:hover {
    color: #111827;
}

/* Profile Dropdown Toggle */
.profile-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: none;
    border: none;
    color: #6b7280;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0;
}

.profile-dropdown-toggle:hover {
    color: #111827;
}

.profile-dropdown-toggle svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
}

.main-content-inner {
    max-width: 1200px;
    margin: 0 auto;
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 35;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.open {
    display: block;
    opacity: 1;
}

/* Responsive - Tablet & Mobile */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .main-content {
        padding: 1.5rem;
    }
}

@media (max-width: 640px) {
    .main-content {
        padding: 1rem;
    }

    .topbar-container {
        padding: 0 1rem;
    }

    .breadcrumb .section-name {
        display: none;
    }
}

/* Sidebar Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: #374151;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}
