/* ==============================================================================
   📸 img.nlink.kr - Content-Focused Minimalist Gallery Style
   - 이미지 중심의 미니멀리즘 디자인 (사진이 가장 돋보이도록 UI 요소 톤다운)
   - 모던 모노크롬 & 슬레이트 팔레트 (튀는 원색/파란색 완전 배제)
   - 모바일 최적화 터치 & 제스처 UI
   ============================================================================== */

:root {
    /* Subtle Monochrome Palette */
    --primary: #18181b;          /* Dark Charcoal */
    --primary-hover: #27272a;    /* Slightly lighter hover */
    --primary-light: #f4f4f5;    /* Soft zinc background */
    --accent: #3f3f46;           /* Muted accent */
    
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;

    --dark: #09090b;
    --gray-900: #18181b;
    --gray-700: #3f3f46;
    --gray-500: #71717a;
    --gray-400: #a1a1aa;
    --gray-300: #e4e4e7;
    --gray-200: #e4e4e7;
    --gray-100: #f4f4f5;
    --gray-50: #fafafa;
    --white: #ffffff;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow-subtle: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-card: 0 2px 8px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
    --shadow-card-hover: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-modal: 0 20px 50px rgba(0,0,0,0.25);

    --font: -apple-system, BlinkMacSystemFont, "Pretendard Variable", Pretendard, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    background-color: #fbfbfb;
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ==============================================================================
   헤더 (Header)
   ============================================================================== */
.app-header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-300);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--dark);
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.3px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.desktop-menu {
    display: flex;
    align-items: center;
    gap: 8px;
}

.desktop-action-btns {
    display: flex;
    gap: 8px;
}

.user-email {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
}

.badge-unlimited {
    background: var(--gray-700);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.quota-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--gray-100);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.quota-bar-mini {
    width: 44px;
    height: 5px;
    background: var(--gray-300);
    border-radius: 3px;
    overflow: hidden;
}

.quota-bar-fill {
    height: 100%;
    background: var(--gray-700);
    border-radius: 3px;
}

/* Mobile Hamburger Menu */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 36px;
    height: 36px;
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 8px 7px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn:active {
    background: var(--gray-200);
}

.mobile-menu-btn .bar {
    width: 100%;
    height: 2px;
    background: var(--gray-700);
    border-radius: 2px;
    pointer-events: none;
}

.mobile-menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-modal);
    padding: 10px;
    z-index: 1000;
}

.mobile-menu-dropdown.open {
    display: block;
    animation: menuFade 0.15s ease;
}

@keyframes menuFade {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.mobile-menu-user {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 8px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--gray-200);
    font-size: 12px;
    color: var(--gray-700);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-menu-user .role-badge {
    background: var(--primary);
    color: #fff;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.mobile-menu-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mobile-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    text-decoration: none;
    border-radius: 6px;
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}

.mobile-menu-item:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.mobile-menu-item.text-danger {
    color: var(--danger);
}

/* ==============================================================================
   메인 컨테이너 및 탭 (Main Layout & Tabs)
   ============================================================================== */
.app-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 20px 100px;
}

.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.tab-nav {
    display: flex;
    gap: 4px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-300);
}

.tab-btn {
    background: none;
    border: none;
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.tab-btn.active {
    color: var(--gray-900);
    background: var(--white);
    font-weight: 600;
    box-shadow: var(--shadow-subtle);
}

/* ==============================================================================
   버튼 (Buttons) - 톤다운된 미니멀 모노크롬 스타일
   ============================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 15px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.2;
}

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

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

.btn-secondary {
    background: var(--white);
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 6px;
}

.btn-block {
    width: 100%;
}

.btn-text-link {
    background: none;
    border: none;
    color: var(--gray-500);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    text-decoration: none;
    transition: color 0.15s;
}

.btn-text-link:hover {
    color: var(--gray-900);
    background: var(--gray-100);
}

/* ==============================================================================
   이미지 카드 그리드 (Image-First Gallery Grid)
   - 사진이 100% 돋보이도록 카드 프레임과 버튼 시각 간섭 최소화
   ============================================================================== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

.image-card, .album-card {
    background: var(--white);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--gray-300);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.image-card:hover, .album-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover);
    border-color: var(--gray-400);
}

.image-card-thumb, .album-card-thumb {
    width: 100%;
    height: 190px;
    background: #f1f1f3;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.image-card-thumb img, .album-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    transition: transform 0.25s ease;
}

.image-card:hover .image-card-thumb img {
    transform: scale(1.02);
}

.dim-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    color: var(--white);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.card-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-meta {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.card-actions {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* 복사 버튼 그룹 - 은은한 아웃라인/그레이 톤으로 시선 분산 방지 */
.btn-copy-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.btn-copy-group .btn {
    font-size: 11px;
    padding: 6px 8px;
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    font-weight: 500;
}

.btn-copy-group .btn:hover {
    background: var(--gray-200);
    color: var(--gray-900);
    border-color: var(--gray-400);
}

.btn-copy-group .btn-shop {
    background: #fdfdfd;
    color: var(--gray-900);
    border-color: #d4d4d8;
    font-weight: 600;
}

.btn-copy-group .btn-shop:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* ==============================================================================
   모바일 플로팅 업로드 버튼 (FAB) - 세련된 다크 원형
   ============================================================================== */
.fab-upload {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
    border: none;
    cursor: pointer;
    z-index: 90;
    transition: transform 0.2s ease, background 0.2s ease;
}

.fab-upload:hover {
    background: var(--primary-hover);
    transform: scale(1.06);
}

/* ==============================================================================
   모달 (Modals)
   ============================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-card {
    background: var(--white);
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900);
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--gray-400);
    cursor: pointer;
    line-height: 1;
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* 드롭존 (Dropzone) */
.dropzone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-md);
    padding: 36px 20px;
    text-align: center;
    background: var(--gray-50);
    cursor: pointer;
    transition: all 0.15s ease;
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: var(--gray-100);
}

.dropzone-icon {
    font-size: 36px;
    margin-bottom: 8px;
    opacity: 0.8;
}

.progress-container {
    margin-top: 16px;
    display: none;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.2s;
}

/* ==============================================================================
   풀스크린 라이트박스 뷰어 (Full-Screen Lightbox)
   ============================================================================== */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    user-select: none;
}

.lightbox-img-wrapper {
    max-width: 92vw;
    max-height: 88vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-img {
    max-width: 100%;
    max-height: 88vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.lightbox-btn {
    position: absolute;
    background: rgba(255, 255, 255, 0.12);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.lightbox-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-close { top: 16px; right: 16px; }

/* ==============================================================================
   토스트 알림 (Toast Notifications)
   ============================================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--dark);
    color: var(--white);
    padding: 10px 18px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 6px;
    animation: toastIn 0.25s ease forwards;
}

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

/* ==============================================================================
   인증 페이지 (Auth Page)
   ============================================================================== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: #f4f4f5;
}

.auth-container {
    width: 100%;
    max-width: 400px;
}

.auth-card {
    background: var(--white);
    padding: 32px 28px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--gray-300);
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.logo-badge {
    font-size: 36px;
    margin-bottom: 6px;
}

.auth-header h1 {
    font-size: 21px;
    font-weight: 700;
    color: var(--dark);
    letter-spacing: -0.4px;
}

.auth-header .subtitle {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 4px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--gray-900);
    transition: all 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(24, 24, 27, 0.1);
}

.password-wrapper {
    position: relative;
}

.btn-toggle-pw {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    color: var(--gray-400);
    padding: 4px;
}

.remember-row {
    margin-bottom: 20px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
    color: var(--gray-700);
    user-select: none;
}

.checkbox-label input {
    margin-right: 8px;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    line-height: 1.4;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fee2e2;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.security-badge {
    font-size: 11px;
    color: var(--gray-400);
    margin-bottom: 8px;
}

.flex-1 {
    flex: 1;
}

/* ==============================================================================
   반응형 모바일 (Responsive Mobile)
   ============================================================================== */
@media (max-width: 768px) {
    .header-inner {
        padding: 8px 14px;
        position: relative;
    }
    .desktop-menu {
        display: none !important;
    }
    .desktop-action-btns {
        display: none !important;
    }
    .mobile-menu-btn {
        display: flex;
    }
    .app-container {
        padding: 12px 12px 90px;
    }
    .action-bar {
        margin-bottom: 12px;
    }
    .tab-nav {
        width: 100%;
        display: flex;
        gap: 2px;
    }
    .tab-btn {
        flex: 1;
        text-align: center;
        padding: 8px 4px;
        font-size: 13px;
    }
    .quota-pill {
        padding: 3px 8px;
        font-size: 11px;
    }
    .quota-bar-mini {
        display: none;
    }
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }
    .image-card-thumb, .album-card-thumb {
        height: 180px; /* Better proportion for vertical phone shots */
    }
    .image-card-thumb img, .album-card-thumb img {
        object-position: top center;
    }
    .card-body {
        padding: 10px;
    }
    .card-title {
        font-size: 13px;
    }
    .card-meta {
        font-size: 11px;
        margin-bottom: 8px;
    }
    .btn-copy-group {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .btn-copy-group .btn {
        font-size: 11px;
        padding: 6px;
    }
    .lightbox-prev, .lightbox-next {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }
}
