/**
 * KBACCOUNTANT - HỆ THỐNG KẾ TOÁN
 * Bản quyền: bctoyz.com, công ty LiLa.,corp
 * Author: Kyobi
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    --info-color: #06b6d4;
    --dark: #1f2937;
    --dark-light: #374151;
    --gray: #6b7280;
    --gray-light: #9ca3af;
    --gray-lighter: #e5e7eb;
    --bg-primary: #f9fafb;
    --bg-white: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--dark);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-white);
    border-right: 1px solid var(--gray-lighter);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
    transition: width 0.3s ease, transform 0.3s ease;
}

/* Sidebar Toggle Button (Mobile) */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 20px;
    box-shadow: var(--shadow-md);
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
}

/* Nav Section Toggle (Accordion) */
.nav-section-toggle {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.nav-section-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

.nav-section-icon {
    font-size: 10px;
    transition: transform 0.3s ease;
    color: var(--gray);
}

.nav-section.collapsed .nav-section-icon {
    transform: rotate(-90deg);
}

.nav-section-content {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, padding 0.3s ease, margin 0.3s ease;
    opacity: 1;
    padding: 0;
    margin: 0;
    display: block;
    visibility: visible;
}

.nav-section.collapsed .nav-section-content {
    max-height: 0 !important;
    opacity: 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    visibility: hidden !important;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--gray-lighter);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

.sidebar-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.sidebar-header h1 a {
    text-decoration: none;
    color: inherit;
    display: inline-block;
    transition: opacity 0.2s, transform 0.2s;
    cursor: pointer;
}

.sidebar-header h1 a:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.sidebar-header .subtitle {
    font-size: 12px;
    opacity: 0.9;
    font-weight: 400;
}

.sidebar-nav {
    padding: 16px 0;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--gray-lighter);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--gray-light);
}

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

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

.nav-section-title {
    padding: 8px 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray);
    margin-bottom: 8px;
}

.nav-item {
    display: block;
    padding: 12px 20px;
    color: var(--dark);
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
    font-weight: 500;
    font-size: 14px;
}

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

.nav-item.active {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
    border-left: 3px solid var(--primary-color);
}

.nav-item i,
.nav-item span[class^="icon-"],
.nav-item .nav-icon {
    width: 20px;
    margin-right: 12px;
    text-align: center;
    display: inline-block;
    font-size: 16px;
}

.nav-item .nav-icon {
    flex-shrink: 0;
}

.nav-item {
    display: flex;
    align-items: center;
}

.nav-item-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .nav-item-text {
    display: none;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
}

/* Top Bar */
.topbar {
    background: var(--bg-white);
    border-bottom: 1px solid var(--gray-lighter);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gray);
    font-size: 14px;
}

.breadcrumb a {
    color: var(--gray);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary-color);
}

.breadcrumb-separator {
    color: var(--gray-light);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.user-menu:hover {
    background: var(--gray-lighter);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

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

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--dark);
}

.user-role {
    font-size: 12px;
    color: var(--gray);
}

.btn-logout {
    padding: 8px 16px;
    background: var(--danger-color);
    color: white;
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-logout:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Content Area */
.content {
    padding: 32px;
}

.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.page-description {
    color: var(--gray);
    font-size: 14px;
}

/* Cards */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--gray-lighter);
}

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

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-lighter);
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-color);
}

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

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.stat-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 4px;
    letter-spacing: -1px;
}

.stat-change {
    font-size: 12px;
    color: var(--success-color);
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.menu-item {
    background: var(--bg-white);
    border: 1px solid var(--gray-lighter);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-decoration: none;
    color: var(--dark);
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.menu-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.menu-item-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius);
    background: rgba(37, 99, 235, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.menu-item-title {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
}

.menu-item-desc {
    font-size: 12px;
    color: var(--gray);
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    background: #ecfdf5;
    border-color: var(--success-color);
    color: #065f46;
}

.alert-error {
    background: #fef2f2;
    border-color: var(--danger-color);
    color: #991b1b;
}

.alert-info {
    background: #eff6ff;
    border-color: var(--info-color);
    color: #1e40af;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.5;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-lighter);
    color: var(--dark);
}

.btn-secondary:hover {
    background: var(--gray-light);
    color: white;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-lighter);
    border-radius: var(--radius);
    font-size: 14px;
    transition: all 0.2s;
    background: var(--bg-white);
    color: var(--dark);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-container::before {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    top: -250px;
    right: -250px;
}

.login-container::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    bottom: -200px;
    left: -200px;
}

.login-box {
    background: var(--bg-white);
    padding: 48px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.login-header .subtitle {
    color: var(--gray);
    font-size: 14px;
}

.login-info {
    margin-top: 24px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    font-size: 13px;
    border: 1px solid var(--gray-lighter);
}

.login-info p {
    margin: 4px 0;
}

.login-info strong {
    color: var(--dark);
    font-weight: 600;
}

.login-footer {
    margin-top: 32px;
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid var(--gray-lighter);
    color: var(--gray);
    font-size: 12px;
}

/* Footer */
.footer {
    background: var(--bg-white);
    border-top: 1px solid var(--gray-lighter);
    padding: 24px 32px;
    text-align: center;
    color: var(--gray);
    font-size: 13px;
    margin-top: auto;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar-toggle {
        display: flex;
    }
    
    .sidebar-overlay {
        display: none;
    }
    
    .sidebar {
        width: 80px;
        transition: width 0.3s ease;
    }
    
    .sidebar.open {
        width: 260px;
    }
    
    .sidebar.open ~ .sidebar-overlay {
        display: block;
    }
    
    .app-wrapper:has(.sidebar:not(.open)) .main-content {
        margin-left: 80px;
        transition: margin-left 0.3s ease;
    }
    
    .app-wrapper:has(.sidebar.open) .main-content {
        margin-left: 260px;
    }
    
    /* Sidebar chỉ hiển thị icon khi đóng */
    .sidebar:not(.open) .sidebar-header h1,
    .sidebar:not(.open) .sidebar-header .subtitle {
        display: none;
    }
    
    .sidebar:not(.open) .nav-section-title span:first-child,
    .sidebar:not(.open) .nav-item-text {
        display: none;
    }
    
    .sidebar:not(.open) .nav-item {
        justify-content: center;
        padding: 12px;
    }
    
    .sidebar:not(.open) .nav-icon {
        margin-right: 0;
    }
    
    .sidebar.open .nav-item {
        justify-content: flex-start;
        padding: 12px 20px;
    }
    
    .sidebar.open .nav-icon {
        margin-right: 12px;
    }
}

@media (max-width: 768px) {
    .content {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .menu-grid {
        grid-template-columns: 1fr;
    }
    
    .topbar {
        padding: 12px 16px;
    }
    
    .user-info-text {
        display: none;
    }
}

/* Icons (using Unicode/Emoji as fallback) */
.icon-dashboard::before { content: "📊 "; }
.icon-users::before { content: "👥 "; }
.icon-warehouse::before { content: "📦 "; }
.icon-product::before { content: "📋 "; }
.icon-stock::before { content: "📥 "; }
.icon-report::before { content: "📈 "; }
.icon-settings::before { content: "⚙️ "; }
.icon-company::before { content: "🏢 "; }
.icon-logout::before { content: "🚪 "; }
