/* =============================================
   ERP Template - Modern CSS with Variables
   ============================================= */

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

/* =============================================
   CSS Variables - Primary & Secondary Colors
   All other colors are derived from these
   ============================================= */
:root {
    /* Primary Colors (logo blue) */
    --primary-color: #0F4C81;
    --primary-hover: #0C3E6A;
    --primary-light: #E3EFF9;
    --primary-dark: #083357;
    --primary-soft: #F1F7FD;
    
    /* Secondary Colors (logo gold accent) */
    --secondary-color: #C6A354;
    --secondary-hover: #AA8840;
    --secondary-light: #F7F0DD;
    
    /* Derived Colors */
    --success-color: #10B981;
    --success-light: #D1FAE5;
    --warning-color: #F59E0B;
    --warning-light: #FEF3C7;
    --danger-color: #EF4444;
    --danger-light: #FEE2E2;
    --info-color: #4FA8D7;
    --info-light: #D9EEF9;
    
    /* Background & Surface */
    --bg-body: #F3F8FC;
    --bg-subtle: #EEF5FB;
    --bg-surface: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --bg-header: #FFFFFF;
    
    /* Text Colors */
    --text-main: #0E2238;
    --text-secondary: #2F4660;
    --text-muted: #5B7187;
    --text-light: #8CA1B5;
    --text-inverse: #FFFFFF;
    
    /* Border Colors */
    --border-color: #D6E2EE;
    --border-light: #E8F0F7;
    --border-focus: var(--primary-color);
    
    /* Border Radius */
    --radius-xs: 0.25rem;
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --header-height: 64px;
    --footer-height: 56px;
    
    /* Typography */
    --font-heading: 'Manrope', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

/* =============================================
   Reset & Base Styles
   ============================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-main);
    background-color: var(--bg-body);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-main);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* =============================================
   Utility Classes
   ============================================= */
.text-primary { color: var(--primary-color); }
.text-secondary { color: var(--secondary-color); }
.text-success { color: var(--success-color); }
.text-warning { color: var(--warning-color); }
.text-danger { color: var(--danger-color); }
.text-muted { color: var(--text-muted); }

.bg-primary { background-color: var(--primary-color); }
.bg-secondary { background-color: var(--secondary-color); }
.bg-success { background-color: var(--success-color); }
.bg-warning { background-color: var(--warning-color); }
.bg-danger { background-color: var(--danger-color); }

/* =============================================
   Login Page Styles
   ============================================= */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    background-color: var(--bg-body);
}

.login-left {
    flex: 1;
    display: none;
    background: var(--bg-body);
    position: relative;
    overflow: hidden;
}

@media (min-width: 992px) {
    .login-left {
        display: none;
    }
}

.login-left::before {
    display: none;
}

.login-left-content {
    position: relative;
    z-index: 1;
    text-align: center;
    color: var(--text-inverse);
    padding: 3rem;
}

.login-left-content h1 {
    color: var(--text-inverse);
    margin-bottom: 1rem;
    font-size: 2.5rem;
}

.login-left-content p {
    font-size: 1.125rem;
    opacity: 0.9;
    max-width: 400px;
}

.login-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 3rem;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo img {
    display: block;
    margin: 0 auto 1rem;
    max-width: 100%;
    height: auto;
}

.login-logo i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: block;
}

.login-logo h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* =============================================
   Lock Screen Styles
   ============================================= */
.lock-screen-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg-body) 100%);
    padding: 2rem;
}

.lock-screen-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 3rem;
    text-align: center;
    animation: fadeInUp 0.5s ease;
}

.lock-avatar {
    width: 100px;
    height: 100px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    border: 4px solid var(--primary-color);
}

.lock-avatar i {
    font-size: 3rem;
    color: var(--primary-color);
}

.lock-screen-card h3 {
    margin-bottom: 0.5rem;
}

.lock-screen-card .user-email {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 2rem;
}

.lock-time {
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    font-family: var(--font-heading);
}

.lock-date {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* =============================================
   Form Elements
   ============================================= */
.form-group {
    margin-bottom: 1.5rem;
}

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

.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-family: var(--font-body);
    color: var(--text-main);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.form-control:hover {
    border-color: var(--text-light);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control::placeholder {
    color: var(--text-light);
}

.input-group {
    position: relative;
}

.input-group .form-control {
    padding-left: 3rem;
}

.input-group .input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 1.125rem;
    transition: color var(--transition-fast);
}

.input-group:focus-within .input-icon {
    color: var(--primary-color);
}

.input-group .toggle-password {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0;
    font-size: 1.125rem;
    transition: color var(--transition-fast);
}

.input-group .toggle-password:hover {
    color: var(--primary-color);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-check input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.form-check label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: 0;
}

.form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.forgot-link {
    font-size: 0.875rem;
    color: var(--primary-color);
}

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

/* =============================================
   Buttons
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: var(--font-body);
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

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

.btn-secondary {
    background-color: var(--secondary-color);
    color: var(--text-inverse);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--secondary-hover);
    transform: translateY(-1px);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover:not(:disabled) {
    background-color: var(--bg-body);
    border-color: var(--text-light);
}

.btn-outline-primary {
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-primary:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: var(--text-inverse);
}

.btn-ghost {
    background-color: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
    background-color: var(--secondary-light);
    color: var(--text-main);
}

.btn-success {
    background-color: var(--success-color);
    color: var(--text-inverse);
}

.btn-danger {
    background-color: var(--danger-color);
    color: var(--text-inverse);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
}

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

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}

.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

.content-wrapper {
    flex: 1;
    padding: 2rem;
    padding-top: calc(var(--header-height) + 2rem);
}

/* =============================================
   Sidebar
   ============================================= */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-normal), transform var(--transition-normal);
    overflow: hidden;
}

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

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    font-size: 1.25rem;
    flex-shrink: 0;
}

.sidebar-logo-text {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition-fast);
}

.sidebar-collapsed .sidebar-logo-text {
    opacity: 0;
    width: 0;
}

.sidebar-toggle {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--secondary-light);
    color: var(--text-main);
}

.sidebar-collapsed .sidebar-toggle {
    transform: rotate(180deg);
}

.sidebar-search {
    position: relative;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    z-index: 2;
}

.sidebar-search input {
    width: 100%;
    padding: 0.625rem 0.875rem 0.625rem 2.25rem;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    outline: none;
    transition: all var(--transition-fast);
}

.sidebar-search input:focus {
    background: var(--bg-surface);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.sidebar-search .sidebar-search-icon {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    pointer-events: none;
}

.sidebar-collapsed .sidebar-search {
    display: none;
}

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

.nav-section {
    padding: 0 0.75rem;
    margin-bottom: 1.5rem;
}

.nav-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    opacity: 1;
    transition: opacity var(--transition-fast);
}

.sidebar-collapsed .nav-section-title {
    opacity: 0;
}

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

.nav-item {
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9375rem;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
}

.nav-link:hover {
    background: var(--secondary-light);
    color: var(--text-main);
}

.nav-link.active {
    background: var(--primary-light);
    color: var(--primary-color);
}

.nav-link i {
    font-size: 1.25rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.nav-link span {
    opacity: 1;
    transition: opacity var(--transition-fast);
}

.sidebar-collapsed .nav-link span {
    opacity: 0;
    width: 0;
}

.nav-link .badge {
    margin-left: auto;
    background: var(--danger-color);
    color: var(--text-inverse);
    font-size: 0.6875rem;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.sidebar-collapsed .nav-link .badge {
    display: none;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.sidebar-user:hover {
    background: var(--secondary-light);
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
    opacity: 1;
    transition: opacity var(--transition-fast);
}

.sidebar-collapsed .sidebar-user-info {
    opacity: 0;
    width: 0;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-main);
    white-space: nowrap;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* =============================================
   Header
   ============================================= */
.header {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    transition: left var(--transition-normal);
}

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

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

.header-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.header-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.header-breadcrumb a {
    color: var(--text-muted);
}

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

.header-breadcrumb i {
    font-size: 0.75rem;
}

.header-search {
    position: relative;
    width: 300px;
}

.header-search input {
    width: 100%;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    outline: none;
    transition: all var(--transition-fast);
}

.header-search input:focus {
    background: var(--bg-surface);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.header-search .header-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.menu-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 280px;
    overflow-y: auto;
    z-index: 2200;
    display: none;
}

.menu-search-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-search-item i {
    flex: 0 0 16px;
    width: 16px;
    text-align: center;
    margin-right: 0.5rem;
}

.menu-search-item span {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-search-item:hover,
.menu-search-item.active {
    background: var(--secondary-light);
}

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

.header-icon-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: all var(--transition-fast);
}

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

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

.header-icon-btn:hover {
    background: var(--secondary-light);
    color: var(--text-main);
}

.header-icon-btn .notification-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-header);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    margin-left: 0.5rem;
}

.header-user:hover {
    background: var(--secondary-light);
}

.header-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.875rem;
}

.header-user-info {
    text-align: left;
}

.header-user-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-main);
}

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

/* =============================================
   DataTables Buttons (Global)
   ============================================= */
.dt-buttons .dt-button,
.dt-buttons .dt-button:active,
.dt-buttons .dt-button:focus {
    background: var(--primary-color) !important;
    color: var(--text-inverse) !important;
    border: 1px solid var(--primary-dark) !important;
    border-radius: var(--radius-md) !important;
    padding: 0.4rem 0.9rem !important;
    font-weight: 600 !important;
    box-shadow: none !important;
}
.dt-buttons .dt-button:hover {
    background: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
}

/* Total row styling */
table.table tfoot th,
table.table tfoot td,
table.data-table tfoot th,
table.data-table tfoot td {
    background: var(--primary-light) !important;
    color: var(--text-main) !important;
    font-weight: 700 !important;
    border-top: 2px solid var(--primary-color) !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
}

/* =============================================
   Footer
   ============================================= */
.footer {
    height: var(--footer-height);
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.footer a {
    color: var(--text-muted);
}

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

/* =============================================
   Cards
   ============================================= */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-body);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* =============================================
   Stats Cards
   ============================================= */
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    transition: all var(--transition-fast);
}

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

.stat-content h3 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.stat-content p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.stat-trend.up {
    color: var(--success-color);
    background: var(--success-light);
}

.stat-trend.down {
    color: var(--danger-color);
    background: var(--danger-light);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-icon.primary {
    background: var(--primary-light);
    color: var(--primary-color);
}

.stat-icon.success {
    background: var(--success-light);
    color: var(--success-color);
}

.stat-icon.warning {
    background: var(--warning-light);
    color: var(--warning-color);
}

.stat-icon.danger {
    background: var(--danger-light);
    color: var(--danger-color);
}

/* =============================================
   Grid Layout
   ============================================= */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: -0.75rem;
}

.col {
    flex: 1;
    padding: 0.75rem;
}

.col-12 { flex: 0 0 100%; max-width: 100%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }

@media (max-width: 1200px) {
    .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
}

@media (max-width: 992px) {
    .col-md-12 { flex: 0 0 100%; max-width: 100%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
}

@media (max-width: 768px) {
    .col-sm-12 { flex: 0 0 100%; max-width: 100%; }
}

/* =============================================
   DataTables Custom Styling
   ============================================= */
.dataTables_wrapper {
    font-size: 0.875rem;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 1rem;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--transition-fast);
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

table.dataTable {
    width: 100% !important;
    border-collapse: collapse;
}

table.dataTable thead th {
    padding: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-body);
    border-bottom: 2px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
}

table.dataTable tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

table.dataTable tbody tr:hover {
    background: var(--secondary-light);
}

table.dataTable tbody tr:last-child td {
    border-bottom: none;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.5rem 0.875rem;
    margin: 0 0.125rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-secondary) !important;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--secondary-light) !important;
    border-color: var(--text-light);
    color: var(--text-main) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary-color) !important;
    border-color: var(--primary-color);
    color: var(--text-inverse) !important;
}

.dataTables_wrapper .dataTables_info {
    color: var(--text-muted);
    padding-top: 1rem;
}

/* =============================================
   Charts Container
   ============================================= */
.chart-container {
    position: relative;
    height: 300px;
}

.chart-container canvas {
    max-height: 100%;
}

/* =============================================
   Dropdown Menu
   ============================================= */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all var(--transition-fast);
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--secondary-light);
    color: var(--text-main);
}

.dropdown-item i {
    width: 1.25rem;
    text-align: center;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

/* =============================================
   Alerts
   ============================================= */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert i {
    font-size: 1.25rem;
    margin-top: 0.125rem;
}

.alert-success {
    background: var(--success-light);
    color: var(--success-color);
    border: 1px solid var(--success-color);
}

.alert-warning {
    background: var(--warning-light);
    color: var(--warning-color);
    border: 1px solid var(--warning-color);
}

.alert-danger {
    background: var(--danger-light);
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.alert-info {
    background: var(--info-light);
    color: var(--info-color);
    border: 1px solid var(--info-color);
}

/* =============================================
   Badge
   ============================================= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary-color);
}

.badge-success {
    background: var(--success-light);
    color: var(--success-color);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning-color);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger-color);
}

/* =============================================
   Avatar
   ============================================= */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    background: var(--primary-light);
    color: var(--primary-color);
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 1.125rem;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-full);
}

/* =============================================
   Activity List
   ============================================= */
.activity-list {
    list-style: none;
}

.activity-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.activity-item:first-child {
    padding-top: 0;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
}

.activity-content p {
    margin-bottom: 0.25rem;
}

.activity-content .activity-time {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* =============================================
   Modal
   ============================================= */
.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: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform var(--transition-fast);
}

.modal-overlay.show .modal {
    transform: scale(1);
}

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

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--secondary-light);
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* =============================================
   Page Header
   ============================================= */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-muted);
}

/* =============================================
   Responsive Styles
   ============================================= */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .header {
        left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-fast);
    }
    
    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
    }
    
    .mobile-menu-btn {
        display: flex !important;
    }
}

@media (min-width: 992px) {
    .mobile-menu-btn {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .content-wrapper {
        padding: 1rem;
        padding-top: calc(var(--header-height) + 1rem);
    }
    
    .header {
        padding: 0 1rem;
    }
    
    .header-user-info {
        display: none;
    }
    
    .stat-card {
        flex-direction: column-reverse;
        align-items: flex-start;
    }
    
    .footer {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
        height: auto;
        padding: 1rem;
    }
}

/* =============================================
   Loading Spinner
   ============================================= */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.global-page-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
}

.global-page-loader.is-active {
    display: block;
}

.global-page-loader__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(2px);
}

.global-page-loader__panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 180px;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.global-page-loader__text {
    color: var(--text-secondary);
    font-weight: 600;
}

/* =============================================
   Tooltip
   ============================================= */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    padding: 0.5rem 0.75rem;
    background: var(--text-main);
    color: var(--text-inverse);
    font-size: 0.75rem;
    border-radius: var(--radius-md);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    z-index: 1000;
}

[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* =============================================
   Quick Actions
   ============================================= */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quick-action-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

.quick-action-btn i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.quick-action-btn span {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* =============================================
   Table Actions
   ============================================= */
.table-actions {
    display: flex;
    gap: 0.5rem;
}

.table-actions .btn-icon {
    width: 32px;
    height: 32px;
    font-size: 0.875rem;
}

.table-actions .action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: var(--primary-color);
    text-decoration: none;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease, color 0.2s ease;
    cursor: pointer;
    padding: 0;
}

.table-actions .action-icon:hover {
    background: var(--primary-soft);
    color: var(--primary-color);
}

/* Status Indicators */
.status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
}

.status-dot.active {
    background: var(--success-color);
}

.status-dot.inactive {
    background: var(--text-light);
}

.status-dot.pending {
    background: var(--warning-color);
}

/* Select2 tweaks for modal dropdown alignment */
.select2-container {
    width: 100% !important;
}

.select2-container--default .select2-selection--single {
    height: 44px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 44px;
    padding-left: 12px;
    padding-right: 24px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 44px;
    right: 8px;
}

.select2-container--open {
    z-index: 3000;
}

.select2-dropdown {
    z-index: 3001;
}

/* Compact line items (2-row grid) */
.line-items-table.compact thead {
    display: none;
}

.line-items-table.compact,
.line-items-table.compact tbody,
.line-items-table.compact tr,
.line-items-table.compact td {
    display: block;
    width: 100%;
}

.line-items-table.compact tbody tr {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.line-items-table.compact tbody td {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.line-items-table.compact tbody td::before {
    content: attr(data-label);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.line-items-table.compact tbody td[data-label=" "]::before {
    content: "";
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.size-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.size-grid-row {
    display: grid;
    grid-template-columns: 120px repeat(auto-fit, minmax(70px, 1fr)) 90px;
    gap: 8px;
    align-items: center;
}

.size-grid-header .size-cell {
    background: var(--primary-light);
    font-weight: 700;
    color: var(--text-main);
}

.size-cell {
    background: var(--bg-subtle);
    padding: 8px 10px;
    border-radius: var(--radius-md);
    text-align: center;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.size-cell.label {
    text-align: left;
    font-weight: 600;
}

.size-cell.total {
    font-weight: 700;
}

.size-input {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px 8px;
    text-align: center;
    font-weight: 600;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.btn.btn-icon {
    padding: 6px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.btn.btn-icon i {
    font-size: 0.85rem;
}

.production-lines-table th,
.production-lines-table td {
    padding: 12px 14px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.production-lines-table th {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.production-lines-table td:nth-child(2) {
    font-weight: 600;
    color: var(--text-main);
}

.production-lines-table .btn.btn-sm {
    padding: 6px 12px;
    border-radius: 999px;
}

.production-lines-table .line-total {
    font-weight: 700;
    color: var(--text-main);
}

@media (max-width: 768px) {
    .production-lines-table th,
    .production-lines-table td {
        padding: 10px;
    }
}

.production-lines-table th:nth-child(1),
.production-lines-table td:nth-child(1) { width: 60px; }
.production-lines-table th:nth-child(3),
.production-lines-table td:nth-child(3) { width: 140px; }
.production-lines-table th:nth-child(4),
.production-lines-table td:nth-child(4) { width: 160px; }
.production-lines-table th:nth-child(5),
.production-lines-table td:nth-child(5) { width: 120px; text-align: right; }

.production-lines-table th:nth-child(3),
.production-lines-table td:nth-child(3) { width: 120px; }
.production-lines-table th:nth-child(4),
.production-lines-table td:nth-child(4) { width: 120px; }
.production-lines-table th:nth-child(5),
.production-lines-table td:nth-child(5) { width: 160px; }
.production-lines-table th:nth-child(6),
.production-lines-table td:nth-child(6) { width: 120px; text-align: right; }

.color-modal .modal {
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(23, 23, 23, 0.12);
}

.color-modal .modal-header {
    background: linear-gradient(120deg, rgba(15, 76, 129, 0.12), rgba(15, 76, 129, 0.02));
    border-bottom: 1px solid var(--border-color);
}

.color-modal .modal-title {
    font-weight: 700;
    color: var(--text-main);
}

.color-modal .modal-body {
    padding: 16px 24px 12px;
}

.color-modal .modal-footer {
    padding: 16px 24px 20px;
    gap: 12px;
}

.color-modal table.table thead th {
    background: var(--primary-light);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-main);
    padding: 10px 12px;
}

.color-modal table.table tbody tr:nth-child(even) {
    background: var(--primary-soft);
}

.color-modal table.table tbody td {
    font-size: 0.88rem;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.color-modal .form-control {
    min-width: 160px;
    height: 36px;
    padding: 6px 10px;
}

.color-modal table.table {
    table-layout: fixed;
    width: 100%;
}

.color-modal table.table th:nth-child(1),
.color-modal table.table td:nth-child(1) { width: 36%; }
.color-modal table.table th:nth-child(2),
.color-modal table.table td:nth-child(2) { width: 16%; text-align: left; }
.color-modal table.table th:nth-child(3),
.color-modal table.table td:nth-child(3) { width: 12%; text-align: center; }
.color-modal table.table th:nth-child(4),
.color-modal table.table td:nth-child(4) { width: 12%; text-align: center; }
.color-modal table.table th:nth-child(5),
.color-modal table.table td:nth-child(5) { width: 24%; }

.color-modal .modal-header {
    padding: 18px 24px;
}

.color-modal .modal-title {
    font-size: 1.1rem;
}

.color-modal .modal-footer .btn {
    min-width: 120px;
}
