:root {
    --bg-body: #0f1115;
    --bg-sidebar: #161b22;
    --bg-card: #1c2128;
    --bg-input: #0d1117;
    --border-color: #30363d;
    --primary-color: #58a6ff;
    --primary-hover: #79c0ff;
    --text-main: #c9d1d9;
    --text-muted: #8b949e;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.2s ease;
    --font-main: 'Inter', 'Noto Sans KR', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: var(--transition);
    z-index: 50;
}

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

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.025em;
}

.sidebar-header .version {
    font-size: 0.75rem;
    color: var(--primary-color);
    background: rgba(88, 166, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    user-select: none;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.04);
    color: #fff;
}

.nav-item.active {
    background-color: rgba(88, 166, 255, 0.1);
    color: var(--primary-color);
}

.nav-item i {
    width: 20px;
    margin-right: 12px;
    text-align: center;
}

.nav-item input {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: #fff;
    padding: 2px 4px;
    border-radius: 3px;
    width: 100%;
    font-family: inherit;
    font-size: inherit;
    cursor: text;
}

/* Dragging state */
.nav-item.dragging {
    opacity: 0.5;
    border: 1px dashed var(--primary-color);
}

.edit-actions {
    margin-left: auto;
    display: none;
    gap: 5px;
}

.nav-item.editing .edit-actions {
    display: flex;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #bc8cff);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.info {
    display: flex;
    flex-direction: column;
}

.info .name {
    color: #fff;
    font-weight: 500;
    font-size: 0.9rem;
}

.info .role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-body);
}

.top-bar {
    height: 70px;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-body);
}

.top-bar h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #fff;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    padding-bottom: 4rem;
    /* Bottom padding for safety */
}

.welcome-screen {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 1rem;
}

.welcome-screen i {
    font-size: 3rem;
    color: var(--border-color);
}

/* Common UI Elements */
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 6px;
    border-radius: 4px;
    transition: var(--transition);
}

.icon-btn:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

/* Input Fields */
input[type="text"],
input[type="date"],
select,
textarea {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    outline: none;
    transition: var(--transition);
    font-family: inherit;
}

/* Fix Date Picker Icon in Dark Mode */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.1);
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
}

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

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

.btn-secondary:hover {
    background-color: #252a32;
    border-color: #8b949e;
}

.btn-danger {
    background-color: rgba(248, 81, 73, 0.1);
    color: #f85149;
    border: 1px solid rgba(248, 81, 73, 0.4);
}

.btn-danger:hover {
    background-color: rgba(248, 81, 73, 0.2);
}

/* Search Box */
.search-global {
    position: relative;
}

.search-global i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-global input {
    padding-left: 32px;
    width: 250px;
    background-color: var(--bg-card);
}

/* --------------------------- */
/*      MOBILE RESPONSIVE      */
/* --------------------------- */

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    /* Top Bar Adjustments */
    .top-bar {
        height: 60px;
        padding: 0 1rem;
        flex-shrink: 0;
    }

    .top-bar h1 {
        font-size: 1.1rem;
    }

    .search-global input {
        width: 150px;
        /* Smaller search box */
        font-size: 0.9rem;
    }

    /* Content Area */
    .content-area {
        padding: 1rem;
        padding-bottom: 80px;
        /* Space for bottom nav */
    }

    /* Sidebar -> Bottom Navigation */
    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        left: 0;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border-color);
        padding: 0;
        background-color: #161b22;
        /* Ensure opacity */
        box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.3);
        justify-content: space-around;
        align-items: center;
    }

    /* Hide elements not needed in Bottom Nav */
    .sidebar-header,
    .sidebar-footer,
    #editSidebarBtn {
        display: none;
    }

    .sidebar-nav {
        flex-direction: row;
        width: 100%;
        justify-content: space-evenly;
        overflow-y: hidden;
        /* No scroll on bottom nav usually */
    }

    .nav-item {
        flex-direction: column;
        padding: 0.6rem 0.2rem;
        border-radius: 0;
        flex: 1;
        justify-content: center;
        gap: 4px;
        font-size: 0.75rem;
    }

    .nav-item i {
        margin: 0;
        font-size: 1.4rem;
        margin-bottom: 2px;
    }

    .nav-item.active {
        background-color: transparent;
        /* Remove bg */
        color: var(--primary-color);
        position: relative;
    }

    .nav-item.active::after {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 20px;
        height: 3px;
        background-color: var(--primary-color);
        border-radius: 0 0 4px 4px;
    }

    /* Table Adjustments */
    .data-table th,
    .data-table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .toolbar h3 {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    #bulkActions {
        width: 100%;
    }

    #toggleEditModeBtn {
        width: 100%;
        justify-content: center;
    }

    /* Input Grid */
    .input-grid {
        grid-template-columns: 1fr;
        /* Stack inputs */
    }

    .form-actions button {
        width: 100%;
        justify-content: center;
    }

    /* Modals */
    .modal-content {
        width: 90% !important;
        margin: 0 1rem;
    }
}