@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+KR:wght@400;500;700&display=swap');

:root {
    --naver-green: #03C75A;
    --naver-dark-green: #02b350;
    --sidebar-bg: #2d3e50;
    --topnav-bg: #283848;
    /* Darker navy */
    --sidebar-text: #adb5bd;
    --sidebar-active: #ffffff;
    --sidebar-hover: #3d4f61;
    --bg-light: #f5f6f7;
    --border-color: #e5e7eb;
    --text-main: #202020;
    --text-muted: #666666;
    --card-bg: #ffffff;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 60px;
    /* Topnav height */
    height: calc(100vh - 60px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Sidebar Scrollbar Styling */
.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-header h1 {
    display: none;
}

.sidebar-nav {
    flex: 1;
    padding: 10px 0;
}

.nav-item {
    margin-bottom: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 8px 15px 8px 30px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover {
    background-color: var(--sidebar-hover);
    color: #fff;
}

.nav-link.active {
    background-color: var(--sidebar-hover);
    color: #fff;
    border-left: 4px solid var(--naver-green);
}

.nav-link i {
    margin-right: 12px;
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
    /* Increased icon size */
}

.sub-menu {
    background-color: rgba(0, 0, 0, 0.1);
    list-style: none;
    padding: 10px 0px 10px 0px;
}

.sub-menu li a {
    padding: 8px 20px 8px 65px;
    /* Reduced indentation and increased vertical padding */
    display: block;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.95rem;
    /* Increased font size for better readability */
    transition: all 0.2s;
}

.sidebar.collapsed .sub-menu {
    display: none !important;
}

.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-link i.fa-chevron-down {
    display: none;
}

.sub-menu li a:hover {
    color: #fff;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 10px 0;
}

.sub-menu li a.active {
    color: var(--naver-green);
    font-weight: 600;
}

.main-wrapper {
    margin-left: 240px;
    margin-top: 60px;
    /* Topnav height */
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-wrapper.expanded {
    margin-left: 70px;
}

.topnav {
    height: 60px;
    background-color: var(--topnav-bg);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.topnav-left {
    display: flex;
    align-items: center;
    height: 100%;
}

.topnav-brand-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 240px;
    /* Match sidebar width */
    padding: 0 5px 0 20px;
    height: 100%;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    margin-right: 0;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    white-space: nowrap;
}

.topnav-brand-wrapper.collapsed {
    width: 70px !important;
    padding: 0 !important;
    justify-content: center !important;
}

.topnav-brand-wrapper.collapsed .toggle-btn {
    margin: 0 !important;
}

/* Hide the logo container when collapsed */
.topnav-brand-wrapper.collapsed>div:first-child,
.topnav-brand-wrapper.collapsed .topnav-brand,
.topnav-brand-wrapper.collapsed .topnav-logo {
    display: none !important;
}

.topnav-logo {
    height: 28px;
    width: 28px;
    object-fit: contain;
    flex-shrink: 0;
}

.topnav-brand {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #fff;
    text-transform: uppercase;
}

.toggle-btn {
    width: 34px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    color: #fff;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
}

.topnav-menu {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: 35px;
}

.topnav-menu a {
    color: #adb5bd;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}

.topnav-menu a:hover,
.topnav-menu a.active {
    color: #fff;
}

.topnav-menu .separator {
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.8rem;
}

.topnav-right {
    display: flex;
    align-items: center;
    gap: 25px;
    padding-right: 20px;
}

.topnav-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: #adb5bd;
}

.topnav-user-icon {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
}

.logout-link {
    color: #adb5bd;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 5px 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    transition: all 0.2s;
}

.logout-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
}

.header {
    display: none;
}

.content {
    padding: 25px 35px;
}

/* Cards & Layout */
.card {
    background-color: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fcfcfc;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background-color: #f9fafb;
    padding: 12px 15px;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

tr:hover {
    background-color: #fcfcfc;
}

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-green {
    background-color: rgba(3, 199, 90, 0.1);
    color: var(--naver-green);
}

/* Controls */
.btn {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--naver-green);
    color: white;
}

.btn-primary:hover {
    background-color: var(--naver-dark-green);
}

.btn-outline {
    border-color: var(--border-color);
    background-color: #fff;
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: #f9fafb;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease-out;
}

/* Dashboard summary */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Table Image Thumbnails */
.product-thumb {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.2s;
}

.product-thumb:hover {
    transform: scale(1.05);
    border-color: var(--naver-green);
}

/* Modal for Image Preview */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.3s ease-out;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
}

@keyframes zoomIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Naver Status Badge */
.naver-status-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #f8f9fa;
    border-radius: 20px;
    border: 1px solid #eee;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ccc;
    position: relative;
}

.status-dot.connected {
    background-color: var(--naver-green);
    box-shadow: 0 0 0 2px rgba(3, 199, 90, 0.2);
}

.status-dot.connected::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--naver-green);
    animation: pulse 2s infinite;
}

.status-dot.disconnected {
    background-color: #ff4d4f;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    70% {
        transform: scale(2.5);
        opacity: 0;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

/* Sidebar Switch Styles */
.sidebar-switch-wrapper {
    margin-right: 12px;
    /* Space between switch and text */
    display: flex;
    align-items: center;
}

.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    /* Reduced size */
    height: 18px;
    /* Reduced size */
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #3d4f61;
    transition: .4s;
    border-radius: 18px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    /* Reduced dot size */
    width: 12px;
    /* Reduced dot size */
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    z-index: 2;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ON/OFF Text Label inside slider */
.slider-text-on,
.slider-text-off {
    position: absolute;
    color: white;
    font-size: 7px;
    /* Reduced font size */
    font-weight: 800;
    top: 50%;
    transform: translateY(-50%);
    transition: .4s;
    letter-spacing: -0.5px;
    pointer-events: none;
}

.slider-text-on {
    left: 5px;
    opacity: 0;
}

.slider-text-off {
    right: 5px;
    opacity: 1;
}

input:checked+.slider {
    background-color: var(--naver-green);
}

input:checked+.slider .slider-text-on {
    opacity: 1;
}

input:checked+.slider .slider-text-off {
    opacity: 0;
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* API Menu & Icons */
.api-menu-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    /* Very tight gap for clean look */
    width: 100%;
}

.api-menu-top {
    display: flex;
    align-items: center;
    width: 100%;
}

.api-menu-top i.fa-link {
    width: 24px;
    text-align: center;
    margin-right: 12px;
    font-size: 1.1rem;
    transform: rotate(-45deg);
    /* Correct rotation for perfectly horizontal view */
    display: inline-block;
}

.api-menu-bottom {
    padding-left: 36px;
    /* Perfect left alignment with the menu label text */
    margin-top: 2px;
}


.toggle-btn:hover {
    background: #f0f0f0;
}

/* Calendar Styles - Premium Refinement */
.calendar-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    border: 1px solid var(--border-color);
    margin-top: 10px;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 40px;
    background: #fcfcfc;
    border-bottom: 1px solid var(--border-color);
}

.calendar-header span {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-main);
    min-width: 160px;
    text-align: center;
}

.calendar-header i {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 10px;
    border-radius: 50%;
    transition: all 0.2s;
}

.calendar-header i:hover {
    background: #f0f0f0;
    color: var(--text-main);
}

.calendar-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 20px;
    text-align: center;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    gap: 10px;
}

.summary-item {
    padding: 10px;
    border-radius: 8px;
    background: #f9fafb;
}

.summary-item .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.summary-item .value {
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
}

.calendar-summary .value.sales {
    color: #3b82f6;
}

.calendar-summary .value.purchase {
    color: #ef4444;
}

.calendar-summary .value.income {
    color: #10b981;
}

.calendar-summary .value.expense {
    color: #f59e0b;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-day-head {
    padding: 12px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: #4b5563;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
}

.calendar-day-head.sun {
    color: #ef4444;
}

.calendar-day-head.sat {
    color: #3b82f6;
}

.calendar-cell {
    min-height: 110px;
    padding: 10px;
    border-right: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
    font-weight: 500;
    color: #1f2937;
    transition: background 0.2s;
    cursor: pointer;
}

.calendar-cell:hover {
    background-color: #f8fafc;
}

.calendar-cell:nth-child(7n) {
    border-right: none;
}

.calendar-cell.prev-month,
.calendar-cell.next-month {
    color: #d1d5db;
    background-color: #fafafa;
}

.calendar-cell.today {
    background-color: #eff6ff;
}

.calendar-cell.today .day-num {
    background: #3b82f6;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.calendar-cell.sun {
    color: #ef4444;
}

.calendar-cell .day-num {
    display: inline-block;
    margin-bottom: 5px;
}