/* Base Styles */
:root {
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --footer-height: clamp(2rem, 2.5vw, 2.5rem);
    --sidebar-width: clamp(14rem, 19vw, 17rem);
    --sidebar-width-collapsed: 70px;
    --layout-max: 1400px;
    --content-gutter: clamp(1rem, 3vw, 2.5rem);
    --space-xs: clamp(0.5rem, 1vw, 0.75rem);
    --space-sm: clamp(0.75rem, 1.5vw, 1.25rem);
    --space-md: clamp(1rem, 2vw, 1.75rem);
    --space-lg: clamp(1.5rem, 3vw, 2.5rem);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100dvh;
}

img,
video,
svg,
canvas,
iframe {
    display: block;
    max-width: 100%;
    height: auto;
}

/* App Layout */
.app-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100dvh;
}

.sidebar.collapsed + .main-wrapper {
    grid-column: 2 / -1;
}

.sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent overflow */
}

.app-header {
    background: var(--bg-secondary);
    padding: 0 clamp(1rem, 3vw, 2.5rem);
    min-height: clamp(3.75rem, 5vw, 4.5rem);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.app-title {
    font-size: 1.5rem;
    color: var(--accent-color);
    font-weight: bold;
}

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

/* Header Icon Buttons (공통 스타일) */
.header-icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    text-decoration: none;
}

.header-icon-btn:hover {
    background: var(--bg-hover);
}

.header-icon-btn svg {
    width: 24px !important;
    height: 24px !important;
    stroke: var(--text-primary) !important;
    stroke-width: 2 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
    fill: none !important;
    transition: all 0.2s ease;
}

.header-icon-btn:hover svg {
    stroke: var(--accent-color) !important;
}

/* User Menu Container */
.user-menu-container {
    position: relative;
}

.user-menu-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--accent-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.user-menu-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.user-menu-btn svg {
    width: 24px !important;
    height: 24px !important;
    stroke: white !important;
    stroke-width: 2 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
    fill: none !important;
}

/* User Dropdown Menu */
.user-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 드롭다운 화살표 */
.user-dropdown::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 16px;
    width: 12px;
    height: 12px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    transform: rotate(45deg);
}

.user-info {
    padding: 1.25rem 1.5rem;
}

.user-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.user-email {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.dropdown-divider {
    margin: 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.2s ease;
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--bg-hover);
}

.dropdown-item:first-of-type {
    border-radius: 0;
}

.dropdown-item svg {
    width: 18px !important;
    height: 18px !important;
    stroke: var(--text-primary) !important;
    stroke-width: 2 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
    fill: none !important;
    flex-shrink: 0;
}

.dropdown-item span {
    font-size: 0.9rem;
}

.logout-item {
    color: var(--danger-color);
}

.logout-item svg {
    stroke: var(--danger-color) !important;
}

.logout-item:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* SVG 아이콘 위치 */
.header-icon-btn .theme-icon-light,
.header-icon-btn .theme-icon-dark {
    position: absolute;
}

/* 테마에 따라 아이콘 표시/숨김 */
:root[data-theme="light"] .header-icon-btn .theme-icon-dark {
    display: none !important;
}

:root[data-theme="light"] .header-icon-btn .theme-icon-light {
    display: block !important;
}

:root[data-theme="dark"] .header-icon-btn .theme-icon-light {
    display: none !important;
}

:root[data-theme="dark"] .header-icon-btn .theme-icon-dark {
    display: block !important;
}

/* 로그아웃 버튼을 링크로 스타일링 */
a.btn-secondary {
    display: inline-block;
    text-decoration: none;
    line-height: 1;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    position: sticky; /* Changed from fixed */
    top: 0;
    height: 100dvh; /* Use dvh for mobile browser UI */
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 100;
}

/* Sidebar Logo */
.sidebar-logo {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    padding-left: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.logo-icon .logo-circle {
    transition: fill 0.3s ease;
}

/* 라이트 모드: 더 어두운 로고 */
:root[data-theme="light"] .logo-icon .logo-circle {
    fill: #1a2332;
}

:root[data-theme="light"] .logo-icon .logo-text-inner {
    fill: white;
}

/* 다크 모드: 밝은 로고 */
:root[data-theme="dark"] .logo-icon .logo-circle {
    fill: #e5e7eb;
}

:root[data-theme="dark"] .logo-icon .logo-text-inner {
    fill: #0a0e17;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    letter-spacing: 2px;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.menu-list {
    list-style: none;
}

.menu-item {
    margin: 0;
}

.menu-link {
    display: block;
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.2s;
}

.menu-link:hover {
    background: var(--bg-hover);
}

.menu-link.active {
    background: var(--accent-color);
    color: white;
    border-right: 3px solid var(--accent-color-dark);
}

.content-area {
    flex: 1;
    padding: 0;
    overflow-y: visible;
    overflow-x: hidden; /* Prevent horizontal scroll */
    display: flex;
    flex-direction: column;
}

.content-area > *:not(.app-footer) {
    padding: var(--space-lg);
}

.app-footer {
    margin-top: auto;
    background: var(--bg-secondary);
    padding: 0.5rem 2rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-left: 0;
    margin-right: 0;
    margin-bottom: 0;
}

/* Always visible footer: fix to bottom and reserve space in content */
.app-footer.fixed {
    position: fixed;
    left: var(--sidebar-width); /* sidebar width */
    right: 0;
    bottom: 0;
    z-index: 50;
    height: var(--footer-height);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: center; /* center text horizontally */
}

.content-area.with-fixed-footer {
    /* constrain content area so the page body doesn't grow beyond viewport
       subtract header (70px) and footer height to avoid body scrollbar */
    max-height: calc(100dvh - 70px - var(--footer-height));
    overflow-y: auto; /* internal scroll if content too tall */
}

.app-footer p {
    margin: 0;
    line-height: 1.5;
}

/* Page Styles */
.webtoon-table-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
}

.history-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.page-container {
    width: min(100%, var(--layout-max));
    margin-inline: auto;
    padding-inline: var(--content-gutter);
    padding-block: var(--space-lg);
}

.page-title {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.welcome-message {
    text-align: center;
    padding: 4rem 2rem;
}

.welcome-message h2 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.welcome-message p {
    color: var(--text-secondary);
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: clamp(1rem, 1.8vw, 1.0625rem);
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-color);
}

.form-group textarea {
    resize: vertical;
}

/* Button Styles */
button, .btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

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

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-info {
    background: #3498db;
    color: white;
}

.btn-info:hover {
    background: #2980b9;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    font-size: 1.2rem;
}

.btn-icon:hover {
    background: var(--bg-hover);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.btn-link {
    background: transparent;
    color: var(--link-color);
    padding: 0.25rem 0.5rem;
    text-decoration: none;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-action {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn-action:hover {
    background: var(--bg-hover);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

/* Table Styles */
table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

table thead {
    background: var(--bg-hover);
}

table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    word-break: break-word;
}

table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    word-break: break-word;
}

table tbody tr:hover {
    background: var(--bg-hover);
}

/* Utility Classes */
.grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--space-md);
}

.hide-on-mobile {
    display: block;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* Loading indicator */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Message styles for file manager feedback */
.success-message {
    background: #e6ffed;
    color: #064e3b;
    border: 1px solid #bbf7d0;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.error-message {
    background: #fff1f2;
    color: #7f1d1d;
    border: 1px solid #fecaca;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.filemanager-page {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.eyebrow-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.filemanager-page .section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.filemanager-page .section-title {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.filemanager-page .section-subtitle {
    color: var(--text-secondary);
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.filemanager-page .header-actions {
    display: flex;
    gap: 0.75rem;
}

.filemanager-page .header-actions button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.filemanager-page .path-panel {    
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.filemanager-page .path-panel .label {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-right: 0.5rem;
}

.filemanager-page .path-chip {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background: var(--bg-primary);
    border: 1px dashed var(--border-color);
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    color: var(--text-primary);
}

.filemanager-page .path-meta .value {
    font-size: 1.25rem;
    font-weight: 600;
    margin-left: 0.35rem;
}

.filemanager-page .breadcrumb-trail {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.filemanager-page .breadcrumb-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.filemanager-page .breadcrumb-link:hover {
    text-decoration: underline;
}

.filemanager-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
}

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

.filemanager-table thead {
    background: var(--bg-primary);
}

.filemanager-table th,
.filemanager-table td {
    padding: 0.85rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.filemanager-table .col-select {
    width: 48px;
}

.filemanager-table .col-action {
    text-align: center;
    width: 140px;
}

.filemanager-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.filemanager-page .name-cell {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    text-decoration: none;
}

.filemanager-page .name-cell.folder {
    color: var(--accent-color);
}

.filemanager-page .type-icon {
    font-size: 1rem;
}

.filemanager-page .pill {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.filemanager-page .pill-folder {
    background: rgba(14, 165, 233, 0.15);
    color: #0ea5e9;
}

.filemanager-page .pill-file {
    background: rgba(99, 102, 241, 0.15);
    color: #6366f1;
}

.filemanager-page .empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.filemanager-page .table-responsive {
    overflow-x: auto;
}

/* Responsive */
@media (max-width: 1024px) {
    .app-container {
        padding-top: 0;
    }

    .main-content {
        flex-direction: column;
    }

    .sidebar {
        position: sticky;
        top: 0;
        left: 0;
        width: 100%;
        max-height: none;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex-direction: column;
        gap: var(--space-xs);
        overflow: visible;
    }

    .sidebar-nav {
        width: 100%;
    }

    .sidebar-footer {
        width: 100%;
    }

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

    .app-footer.fixed {
        position: static;
        height: auto;
        left: 0;
        right: 0;
    }

    .dashboard-content {
        grid-template-columns: 1fr;
    }
    
    .dashboard-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: var(--space-sm);
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-xs);
    }

    .content-area > *:not(.app-footer) {
        padding: var(--space-md);
    }

    .page-container {
        padding-inline: var(--space-sm);
    }

    .grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .hide-on-mobile {
        display: none !important;
    }

    .webtoon-table th,
    .webtoon-table td,
    .history-table th,
    .history-table td {
        padding: 0.75rem 0.5rem;
        font-size: clamp(0.85rem, 2.2vw, 0.95rem);
    }

    .webtoon-id-cell,
    .zip-cell,
    .telegram-cell,
    .history-table td,
    .history-table .time-cell,
    .history-table .webtoon-id-cell,
    .history-table .url-cell,
    .history-table .status-cell,
    .history-table .action-cell,
    .history-table .zip-cell,
    .history-table .telegram-cell {
        white-space: normal;
        overflow: visible;
        text-overflow: initial;
    }

    .history-controls {
        flex-direction: column;
        align-items: stretch !important;
    }

    .theme-toggle-container {
        flex-direction: row;
        gap: 0.5rem;
        padding: 0.4rem;
    }
    
    .theme-option {
        padding: 1rem 1.5rem;
        min-width: 100px;
    }
}

/* Page Title in Header */
.page-title-header {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Sidebar Toggle */
.sidebar-toggle {
    width: 100%;
    background: transparent;
    border: none;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--accent-color);
}

.sidebar-toggle:hover .hamburger-icon {
    stroke: var(--accent-color);
}

.hamburger-icon {
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.toggle-text {
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

/* Collapsed Sidebar */
.sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
}

.sidebar.collapsed .menu-text,
.sidebar.collapsed .logo-text,
.sidebar.collapsed .toggle-text {
    display: none;
}

.sidebar.collapsed .menu-link {
    justify-content: center;
    padding: 0.75rem;
}

/* Menu Icons */
.menu-icon {
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.menu-link {
    display: flex;
    align-items: center;
}

/* Dashboard Styles */
.dashboard-container {
    padding: 1.5rem 1.5rem 0.5rem 1.5rem;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem 1.5rem;
    transition: all 0.2s ease;
    height: 150px;
    position: relative;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.stat-label {
    font-size: 1.0rem;
    color: var(--text-secondary);
}

.stat-header svg {
    color: var(--text-secondary);
    opacity: 0.6;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stat-change {
    font-size: 1.1rem;
    font-weight: 500;
}

.stat-change.positive {
    color: #10b981;
}

.stat-change.negative {
    color: #ef4444;
}

.stat-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.dashboard-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

.dashboard-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.works-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-height: 420px;
    overflow-y: auto;
}

.work-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.work-item:hover {
    background: var(--bg-hover);
}

.work-thumbnail {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
}

.thumbnail-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
}

.work-info {
    flex: 1;
}

.work-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.work-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
}

.work-stats {
    text-align: right;
}

.work-views {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.work-change {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.work-change.positive {
    color: #10b981;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
    margin-bottom: 0.75rem;
    transition: all 0.2s ease;
}

.upload-area:hover {
    border-color: var(--accent-color);
    background: var(--bg-hover);
}

.upload-area svg {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.upload-area p {
    color: var(--accent-color);
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.btn-upload {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

@media (max-width: 640px) {
    .dashboard-stats {
        grid-template-columns: 1fr;
    }
    
    .page-title-header {
        display: none;
    }
}

/* History Table Enhancements */
.history-controls {
    display: flex !important;
    gap: 0.75rem;
    margin-bottom: 1rem;
    justify-content: flex-end !important;
}

.btn-clear {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #ef4444 !important;
    color: white !important;
    border: none !important;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-clear:hover {
    background: #dc2626 !important;
    transform: translateY(-1px);
}

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

.btn-refresh {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #10b981 !important;
    color: white !important;
    border: none !important;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-refresh:hover {
    background: #059669 !important;
    transform: translateY(-1px);
}

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

.checkbox-cell {
    text-align: center;
    padding: 0.75rem !important;
}

.history-checkbox, #select-all {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;   /* ← 이 값을 더 작게 (예: 0.5rem) */
    padding: 1rem 0;      /* ← 이 값을 더 작게 (예: 0.25rem 0) */
}

.page-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.page-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.page-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.text-muted {
    color: var(--text-secondary);
    font-style: italic;
}

/* Management table: ensure full height and no inner scroll */
.webtoon-table-wrapper,
.webtoon-table-wrapper .webtoon-table,
.webtoon-table-wrapper table,
.webtoon-table-wrapper table tbody {
    max-height: none !important;
    overflow: visible !important;
    height: auto !important;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem !important;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.webtoon-id-cell {
    text-align: center;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.zip-cell {
    text-align: center;
    white-space: nowrap;
}

.zip-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--accent-color);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.zip-link:hover {
    background: var(--bg-hover);
    text-decoration: none;
}

.zip-link svg {
    flex-shrink: 0;
}

.table-url-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.table-url-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.telegram-cell {
    text-align: center;
    white-space: nowrap;
}

.btn-telegram {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1.25rem;
    background: #0088cc !important;
    color: white !important;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-width: 90px;
}

.btn-telegram:hover {
    background: #0077b5 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 136, 204, 0.4);
}

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

.btn-telegram svg {
    flex-shrink: 0;
}

/* 모든 테이블 셀이 한 줄로 표시되도록 */
.history-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-table .time-cell,
.history-table .webtoon-id-cell,
.history-table .url-cell,
.history-table .status-cell,
.history-table .action-cell,
.history-table .zip-cell,
.history-table .telegram-cell {
    white-space: nowrap;
}

/* Spin animation for telegram button */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
