/* Turbo Progress Bar */
#turbo-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    z-index: 9999;
    transition: width 0.2s ease-out, opacity 0.2s;
    width: 0%;
}

:root {
    /* Prevent dark mode flash */
    color-scheme: light;

    /* Notion-like Palette (Light Mode) */
    --bg-primary: #FFFFFF;
    --bg-sidebar: #F7F7F5;
    --bg-hover: #EFEFEF;
    --bg-active: #E5E5E5;

    --border-color: #E9E9E7;
    --border-dark: #D4D4D4;

    --text-primary: #37352F;
    --text-secondary: #787774;
    --text-tertiary: #9B9A97;
    --text-placeholder: #B0B0B0;

    --accent-blue: #000000;
    /* Black Theme */

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05);

    /* Typography */
    --font-sans: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, "Apple Color Emoji", Arial, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
    --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;

    /* Prevent flickering on page load */
    --transition-speed: 0s;
}

/* Enable transitions after page load */
html.loaded {
    --transition-speed: 0s;
    /* Instant simple transitions */
}

/* Prevent flash of unstyled content */
html:not(.loaded) body {
    opacity: 0;
}

[data-theme="dark"] {
    /* Prevent dark mode flash */
    color-scheme: dark;

    /* Notion-like Palette (Dark Mode) */
    --bg-primary: #191919;
    --bg-sidebar: #202020;
    --bg-hover: #2C2C2C;
    --bg-active: #373737;

    --border-color: #2F2F2F;
    --border-dark: #3F3F3F;

    --text-primary: #FFFFFF;
    --text-secondary: #9B9A97;
    --text-tertiary: #6B6B6B;
    --text-placeholder: #5A5A5A;

    --accent-blue: #FFFFFF;
    /* White Accent in Dark Mode */

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
}

@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.8/dist/web/static/pretendard.css");
/* Material Symbols imported via JS in common.js for reliability */

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

body {
    font-family: var(--font-sans);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
    opacity: 1;
    -webkit-tap-highlight-color: transparent;
    /* Mobile focus effect removal */
}

/* No Background Animation */
body::before {
    display: none;
}

a {
    text-decoration: none;
    color: inherit;
}

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

/* Sidebar */
.sidebar {
    width: 240px;
    /* Slightly narrower like Notion */
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 12px 8px;
    flex-shrink: 0;
    position: fixed;
    height: 100vh;
    top: 0;
    left: 0;
    overflow-y: hidden;
    /* Prevent full sidebar scroll */
    z-index: 100;
    transition: transform 0.2s ease;
}

.sidebar-header {
    padding: 8px 8px 16px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.1s;
    width: 100%;
}

.user-profile:hover {
    background: var(--bg-hover);
}

.avatar {
    width: 20px;
    height: 20px;
    background: #E3E2E0;
    color: var(--text-secondary);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    box-shadow: none;
}

.username {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.close-sidebar-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 4px;
}

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

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    /* Scroll only the list */
    padding-bottom: 20px;
}

.nav-section {
    margin-bottom: 16px;
}

.section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0 8px;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    margin-bottom: 1px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 400;
    transition: background 0.1s;
    min-height: 28px;
}

.nav-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 500;
}

.nav-item .material-symbols-rounded {
    margin-right: 8px;
    font-size: 18px;
    color: var(--text-secondary);
}

.nav-item:hover .material-symbols-rounded,
.nav-item.active .material-symbols-rounded {
    color: var(--text-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--bg-primary);
    transition: margin-left 0.2s ease;
}

.top-bar {
    height: 48px;
    display: flex;
    align-items: center;
    padding: 0 96px;
    /* Notion-like wide padding */
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 90;
    border-bottom: none;
}

.menu-toggle-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    margin-right: 12px;
    color: var(--text-primary);
    padding: 4px;
    border-radius: 4px;
}

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

.breadcrumbs {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 400;
}

.separator {
    margin: 0 6px;
    color: var(--text-tertiary);
}

.breadcrumb-item.current-page {
    color: var(--text-primary);
    font-weight: 400;
}

.content-area {
    flex: 1;
    padding: 40px 60px 80px 60px;
    /* Standardized padding */
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

/* Page Header */
.page-header {
    margin-bottom: 32px;
    text-align: left;
    /* Left align like Notion */
}

.header-icon-wrapper {
    width: auto;
    height: auto;
    background: none;
    border-radius: 0;
    display: block;
    margin: 0 0 16px 0;
    box-shadow: none;
}

.header-icon-wrapper .material-symbols-rounded {
    font-size: 78px;
    color: var(--text-primary);
    /* Default icon color */
}

h1 {
    font-size: 40px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.description {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
    max-width: 100%;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.tool-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 16px;
    cursor: pointer;
    transition: background 0.1s;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    display: none;
}

.tool-card:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border-color);
    background: var(--bg-hover);
}

.card-icon {
    font-size: 24px;
    margin-bottom: 12px;
    background: none;
    width: auto;
    height: auto;
    display: block;
    border-radius: 0;
    box-shadow: none;
}

.card-icon .material-symbols-rounded {
    font-size: 24px;
    color: var(--text-primary);
}

.tool-card:hover .card-icon {
    transform: none;
}

.card-title {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 15px;
    color: var(--text-primary);
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 2px;
    transition: text-decoration-color 0.1s;
}

.tool-card:hover .card-title {
    text-decoration-color: var(--text-primary);
}

.card-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Tool Container - NO PADDING to align with page header */
.tool-container {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    border: none;
}

/* Global Drop Zone / Upload Area */
.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 0;
    /* Clear padding, use flex for centering */
    height: 200px;
    /* Fixed Height for consistency */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-primary);
    margin-bottom: 24px;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--border-color);
    /* No border change on hover */
    background: var(--bg-hover);
}

[data-theme="dark"] .drop-zone:hover,
[data-theme="dark"] .drop-zone.dragover {
    border-color: var(--border-color);
    /* No border change in dark mode either */
}

.drop-zone .upload-icon {
    font-size: 48px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.drop-zone .upload-text {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}

.drop-zone .upload-hint {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* Inputs & Textareas */
textarea,
input[type="text"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.1s;
    outline: none;
    box-shadow: none;
}

textarea:focus,
input:focus,
select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
    /* Black shadow */
    background: var(--bg-primary);
}

textarea::placeholder,
input::placeholder {
    color: var(--text-placeholder);
}

/* Custom Checkbox & Radio */
input[type="checkbox"],
input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 1px solid var(--border-dark);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    vertical-align: middle;
    transition: all 0.2s;
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
    background-color: var(--accent-blue);
    border-color: var(--accent-blue);
}

input[type="checkbox"]:checked::after {
    content: '✔';
    position: absolute;
    color: white;
    /* Always white checkmark */
    font-size: 14px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

[data-theme="dark"] input[type="checkbox"]:checked::after {
    color: black;
    /* Black checkmark on white accent in dark mode */
}

input[type="radio"] {
    border-radius: 50%;
}

input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

[data-theme="dark"] input[type="radio"]:checked::after {
    background: black;
}

/* Custom Range Slider */
input[type="range"] {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    border: none;
    padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-blue);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.1s;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: none;
}

.btn:hover {
    background-color: var(--bg-hover);
    transform: none;
    box-shadow: none;
}

.btn:active {
    transform: none;
    background-color: var(--bg-active);
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
    /* Always white text on black button in light mode */
    border: 1px solid var(--accent-blue);
    box-shadow: none;
}

[data-theme="dark"] .btn-primary {
    color: black;
    /* Black text on white button in dark mode */
}

.btn-primary:hover {
    background-color: #333333;
    /* Dark Grey hover */
    box-shadow: none;
    transform: none;
}

[data-theme="dark"] .btn-primary:hover {
    background-color: #E0E0E0;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 32px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 14px;
    border: 1px solid var(--border-color);
    margin-top: 24px;
    justify-content: flex-start;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.stat-item strong {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #D4D4D4;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #A0A0A0;
}

/* Force Material Symbols Font */
.material-symbols-rounded {
    font-family: 'Material Symbols Rounded', sans-serif !important;
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    font-feature-settings: 'liga';
    -webkit-font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    font-display: block;
    /* Prevent text showing before icon loads */
}

/* Custom Modal System */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    animation: fadeIn 0.2s forwards;
}

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

.modal-container {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    animation: modalPop 0.2s forwards;
}

@keyframes modalPop {
    to {
        transform: scale(1);
    }
}

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

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--bg-hover);
}

.modal-body {
    padding: 24px;
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.6;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        border-right: 1px solid var(--border-color);
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
    }

    .close-sidebar-btn {
        display: block;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }

    .top-bar {
        padding: 0 16px;
    }

    .menu-toggle-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--text-primary);
        padding: 8px;
        margin-right: 8px;
        border-radius: 8px;
    }

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

    .content-area {
        padding: 24px 16px;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .stats-bar {
        flex-direction: column;
        gap: 16px;
    }

    h1 {
        font-size: 32px !important;
    }

    .page-header h1 {
        font-size: 32px !important;
    }

    .description {
        font-size: 16px !important;
    }

    /* Tool cards on mobile */
    .tool-card {
        padding: 16px !important;
    }

    .card-icon {
        width: 40px !important;
        height: 40px !important;
    }

    .card-title {
        font-size: 13px !important;
    }

    .card-desc {
        font-size: 11px !important;
    }

    /* Improve button sizing on mobile */
    .btn {
        min-height: 44px;
        padding: 10px 16px;
    }

    /* Better input sizing on mobile */
    textarea,
    input[type="text"],
    input[type="number"],
    input[type="date"],
    select {
        min-height: 44px;
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

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

    /* Header icon on mobile */
    .header-icon-wrapper {
        width: auto !important;
        height: auto !important;
    }

    .header-icon-wrapper .material-symbols-rounded {
        font-size: 64px !important;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    .card-desc {
        display: none !important;
    }
}