/* -------------------------------------------------------------
   AL-Malik Textile Inventory System - Design System Stylesheet
------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Color Palette - Light Mode Default */
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-sidebar: #0f172a;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-light: #ffffff;
    
    --accent-gold: #c5a880;
    --accent-gold-hover: #b09166;
    --accent-gold-light: rgba(197, 168, 128, 0.15);
    
    --accent-teal: #1e293b;
    --accent-teal-light: #f1f5f9;
    
    --surface-card: #ffffff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
    --shadow-gold: 0 4px 14px 0 rgba(197, 168, 128, 0.4);
    
    /* Semantic Colors */
    --color-success: #10b981;
    --color-success-light: rgba(16, 185, 129, 0.15);
    --color-warning: #f59e0b;
    --color-warning-light: rgba(245, 158, 11, 0.15);
    --color-danger: #ef4444;
    --color-danger-light: rgba(239, 68, 68, 0.15);
    --color-info: #3b82f6;
    --color-info-light: rgba(59, 130, 246, 0.15);
    
    /* Layout Constants */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --navbar-height: 70px;
    --border-radius-sm: 6px;
    --border-radius-md: 12px;
    --border-radius-lg: 18px;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Variables Override */
[data-theme="dark"] {
    --bg-primary: #090a0f;
    --bg-secondary: #12131a;
    --bg-sidebar: #050608;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-gold: #e2c29b;
    --accent-gold-hover: #f0d5b5;
    --accent-gold-light: rgba(226, 194, 155, 0.15);
    
    --accent-teal: #1e293b;
    --accent-teal-light: #0f172a;
    
    --surface-card: #161722;
    --border-color: #262837;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

/* Global Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

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

button, input, select, textarea {
    font-family: inherit;
    color: inherit;
}

/* Main Container Layout */
#app-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Sidebar Styling */
#sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width var(--transition-normal);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.15);
    overflow-x: hidden;
    overflow-y: auto;
}

#sidebar::-webkit-scrollbar {
    width: 4px;
}
#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

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

.sidebar-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    width: 100%;
    padding: 20px 15px;
    justify-content: space-between;
    transition: padding var(--transition-normal);
}

#sidebar.collapsed .sidebar-wrapper {
    padding: 20px 8px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px 25px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 20px;
    overflow: hidden;
    white-space: nowrap;
}

#sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 10px 0 25px 0;
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-gold);
    box-shadow: var(--shadow-gold);
    background-color: #ffffff;
}

.brand-name {
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #ffffff 0%, var(--accent-gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: opacity var(--transition-normal);
    opacity: 1;
}

#sidebar.collapsed .brand-name {
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
    overflow: hidden;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.menu-section {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 15px 10px 5px 10px;
    transition: opacity var(--transition-normal);
    white-space: nowrap;
}

#sidebar.collapsed .menu-section {
    opacity: 0;
    height: 0;
    padding: 0;
    overflow: hidden;
}

.menu-item {
    display: flex;
    flex-direction: column;
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 14px;
    border-radius: var(--border-radius-md);
    color: rgba(255, 255, 255, 0.75);
    font-weight: 500;
    font-size: 0.92rem;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

#sidebar.collapsed .menu-item a {
    justify-content: center;
    padding: 12px 0;
    gap: 0;
}

.menu-item a svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

.menu-item:hover a {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.05);
}

.menu-item:hover a svg {
    transform: scale(1.1);
}

.menu-item.active > a {
    background-color: var(--accent-gold-light);
    color: var(--accent-gold);
    font-weight: 600;
    box-shadow: inset 4px 0 0 var(--accent-gold);
}

#sidebar.collapsed .menu-item a span {
    display: none;
}

/* Submenu Styling */
.chevron-icon {
    margin-left: auto;
    transition: transform var(--transition-normal);
}

.has-submenu.open .chevron-icon {
    transform: rotate(180deg);
}

.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-normal), margin var(--transition-normal), padding var(--transition-normal);
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: var(--border-radius-md);
}

.has-submenu.open .submenu {
    max-height: 300px;
    margin-top: 4px;
    margin-bottom: 4px;
    padding: 6px 0;
}

.submenu li a {
    display: block;
    padding: 8px 20px 8px 45px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.65);
    font-weight: 500;
    transition: all var(--transition-fast);
    border-radius: 0;
    background: none !important;
    box-shadow: none !important;
}

.submenu li a:hover {
    color: #ffffff;
    padding-left: 49px;
    background: none;
}

.submenu li.active a {
    color: var(--accent-gold);
    font-weight: 600;
}

#sidebar.collapsed .submenu {
    display: none !important;
}

#sidebar.collapsed .menu-item a .chevron-icon {
    display: none;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 15px;
}

/* Main Content Wrapper */
#main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    min-width: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-normal);
}

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

/* Navbar */
#top-navbar {
    height: var(--navbar-height);
    background-color: var(--surface-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: var(--shadow-sm);
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--border-radius-md);
    transition: background-color var(--transition-fast);
}

.sidebar-toggle-btn:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.search-box {
    position: relative;
    width: 280px;
}

.search-box input {
    width: 100%;
    padding: 9px 15px 9px 40px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    font-size: 0.88rem;
    outline: none;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--accent-gold);
    background-color: var(--surface-card);
    box-shadow: 0 0 0 3px var(--accent-gold-light);
}

.search-box svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.currency-widget {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--border-radius-md);
    font-size: 0.82rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}

.currency-badge {
    background-color: var(--accent-gold-light);
    color: var(--accent-gold);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.theme-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast);
}

.theme-toggle-btn:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.user-profile-menu {
    position: relative;
    cursor: pointer;
}

.profile-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px;
    border-radius: 30px;
    transition: background-color var(--transition-fast);
}

.profile-trigger:hover {
    background-color: var(--bg-secondary);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--accent-gold);
    color: #ffffff;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.88rem;
}

.user-info-text {
    display: flex;
    flex-direction: column;
    text-align: left;
    padding-right: 10px;
}

.user-info-text .name {
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.2;
}

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

/* Page Body Container */
.page-container {
    padding: 30px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* Typography & Headers */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-title-area {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Metrics Dashboard Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.metric-card {
    background-color: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.metric-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-gold-light);
}

.metric-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.metric-card:hover::after {
    transform: translateX(100%);
}

.metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.metric-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-md);
    background-color: var(--bg-secondary);
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: background-color var(--transition-fast);
}

.metric-card:hover .metric-icon {
    background-color: var(--accent-gold-light);
}

.metric-trend {
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 30px;
}

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

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

.metric-value {
    font-size: 1.88rem;
    font-weight: 700;
    letter-spacing: -0.8px;
}

.metric-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Content Panel Surfaces */
.content-card {
    background-color: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

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

.card-title {
    font-size: 1.12rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 25px;
}

/* Beautiful Modern Tables */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.table-modern {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.table-modern th {
    padding: 16px 20px;
    font-weight: 700;
    color: var(--text-secondary);
    background-color: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.8px;
}

.table-modern td {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.table-modern tbody tr {
    transition: background-color var(--transition-fast);
}

.table-modern tbody tr:hover {
    background-color: rgba(197, 168, 128, 0.04);
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: fit-content;
}

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

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

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

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

/* Professional Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--border-radius-md);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    outline: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--accent-gold);
    color: var(--bg-primary);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background-color: var(--accent-gold-hover);
    box-shadow: var(--shadow-gold);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

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

.btn-danger {
    background-color: var(--color-danger);
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-outline-gold {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    background: transparent;
}

.btn-outline-gold:hover {
    background-color: var(--accent-gold-light);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: var(--border-radius-sm);
}

/* Elegant Form Controls */
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 11px 15px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: all var(--transition-fast);
}

.form-control:focus {
    border-color: var(--accent-gold);
    background-color: var(--surface-card);
    box-shadow: 0 0 0 3px var(--accent-gold-light);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Invoicing Interface specific grid layout */
.invoice-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}

@media (max-width: 1024px) {
    .invoice-grid {
        grid-template-columns: 1fr;
    }
}

.invoice-summary-box {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.invoice-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.invoice-summary-row.total {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    border-top: 1px dashed var(--border-color);
    padding-top: 15px;
    margin-top: 10px;
}

/* Message Alerts notifications */
.alert-banner {
    padding: 15px 20px;
    border-radius: var(--border-radius-md);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    font-size: 0.9rem;
}

.alert-banner.success {
    background-color: var(--color-success-light);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.alert-banner.error {
    background-color: var(--color-danger-light);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Print Receipt Layout */
@media print {
    body {
        background-color: #ffffff !important;
        color: #000000 !important;
    }
    #sidebar, #top-navbar, .sidebar-toggle-btn, .theme-toggle-btn, .btn, .page-subtitle {
        display: none !important;
    }
    #main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    .page-container {
        padding: 0 !important;
    }
    .content-card {
        border: none !important;
        box-shadow: none !important;
    }
    .invoice-receipt {
        max-width: 80mm;
        margin: 0 auto;
        font-family: monospace;
        font-size: 12px;
    }
}

/* -------------------------------------------------------------
   Modal Overlay & Content Styles (Glassmorphism & Slide Animations)
------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(5, 6, 8, 0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background-color: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(-30px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

.modal-card.modal-md {
    max-width: 700px;
}

.modal-card.modal-lg {
    max-width: 950px;
}

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

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    font-weight: 300;
    cursor: pointer;
    color: var(--text-muted);
    transition: color var(--transition-fast);
    line-height: 1;
}

.modal-close-btn:hover {
    color: var(--color-danger);
}

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

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

/* Toast Notification Styles */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1100;
}

.toast {
    background-color: var(--surface-card);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-gold);
    border-radius: var(--border-radius-md);
    padding: 14px 20px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    transform: translateX(120%);
    transition: transform var(--transition-normal);
}

.toast.active {
    transform: translateX(0);
}

.toast.success {
    border-left-color: var(--color-success);
}

.toast.error {
    border-left-color: var(--color-danger);
}

.toast.info {
    border-left-color: var(--color-info);
}

.toast-message {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* -------------------------------------------------------------
   Pagination Layout & Elements
------------------------------------------------------------- */
.pagination-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-top: 1px solid var(--border-color);
    background-color: var(--surface-card);
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
    gap: 15px;
}

.pagination-info {
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.pagination-limit-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-limit-form select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
    font-size: 0.82rem;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.pagination-limit-form select:focus {
    border-color: var(--accent-gold);
}

.pagination-nav {
    display: flex;
    align-items: center;
    gap: 5px;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 6px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--surface-card);
    color: var(--text-primary);
    font-weight: 600;
    transition: all var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
    user-select: none;
}

.page-btn:hover:not(.disabled):not(.active) {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    background-color: var(--accent-gold-light);
}

.page-btn.active {
    background-color: var(--accent-gold);
    color: var(--bg-primary);
    border-color: var(--accent-gold);
    cursor: default;
}

.page-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: var(--bg-secondary);
    color: var(--text-muted);
}


/* -------------------------------------------------------------
   Professional Actions Dropdown Component
------------------------------------------------------------- */
.actions-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
}

.actions-dropdown-btn {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    line-height: 1;
}

.actions-dropdown-btn:hover,
.actions-dropdown.open .actions-dropdown-btn {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.actions-dropdown-menu {
    position: fixed;
    z-index: 1100; /* Ensure it floats above modals and headers */
    min-width: 170px;
    background-color: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px) scale(0.97);
    transition: opacity 0.15s ease, transform 0.15s ease;
    overflow: hidden;
}

.actions-dropdown.open .actions-dropdown-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.actions-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    text-align: left;
    transition: background-color var(--transition-fast), color var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.actions-dropdown-item:hover {
    background-color: var(--bg-secondary);
    color: var(--accent-gold);
}

.actions-dropdown-item.danger {
    color: var(--color-danger);
}

.actions-dropdown-item.danger:hover {
    background-color: var(--color-danger-light);
    color: var(--color-danger);
}

.actions-dropdown-item svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.8;
}

.actions-dropdown-separator {
    height: 1px;
    background-color: var(--border-color);
    margin: 4px 0;
}

/* Ensure table rows with open dropdowns stay visible above siblings */
.table-modern tbody tr:has(.actions-dropdown.open) {
    z-index: 10;
    position: relative;
}

/* Spinner Button Animations */
@keyframes rotate-spinner {
    100% {
        transform: rotate(360deg);
    }
}
@keyframes dash-spinner {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}
.spinner-btn {
    animation: rotate-spinner 2s linear infinite;
}
.spinner-btn .path {
    stroke: currentColor;
    stroke-linecap: round;
    animation: dash-spinner 1.5s ease-in-out infinite;
}

/* =============================================================
   Profile Dropdown & Avatar Upload Styling
   ============================================================= */
.user-profile-menu {
    position: relative;
}

.user-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-gold);
    transition: border-color var(--transition-fast);
}

.profile-trigger:hover .user-avatar-img {
    border-color: var(--accent-gold-hover);
}

.dropdown-chevron {
    color: var(--text-muted);
    transition: transform var(--transition-fast), color var(--transition-fast);
}

.profile-trigger:hover .dropdown-chevron {
    color: var(--text-primary);
}

.user-profile-menu.open .dropdown-chevron {
    transform: rotate(180deg);
}

.profile-dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 240px;
    background-color: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    padding: 8px 0;
    z-index: 1000;
    transform: translateY(10px);
    opacity: 0;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.profile-dropdown-menu.show {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

.dropdown-header {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dropdown-user-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.dropdown-user-email {
    font-size: 0.75rem;
    color: var(--text-muted);
    word-break: break-all;
}

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

.profile-dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.profile-dropdown-menu .dropdown-item:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.profile-dropdown-menu .dropdown-item svg {
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.profile-dropdown-menu .dropdown-item:hover svg {
    color: var(--accent-gold);
}

.profile-dropdown-menu .dropdown-item.logout-link:hover {
    background-color: rgba(239, 68, 68, 0.08);
    color: var(--color-danger);
}

.profile-dropdown-menu .dropdown-item.logout-link:hover svg {
    color: var(--color-danger);
}

/* --- Customer Autocomplete Search Styles --- */
.customer-search-container {
    position: relative;
    width: 100%;
}

.customer-search-results-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
    z-index: 1050;
    max-height: 250px;
    overflow-y: auto;
    margin-top: 4px;
}

.customer-search-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast), color var(--transition-fast);
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.customer-search-item:last-child {
    border-bottom: none;
}

.customer-search-item:hover {
    background: var(--bg-secondary);
    color: var(--accent-gold);
}

.customer-search-item .phone-badge {
    font-size: 0.72rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}


/* =============================================================
   MOBILE SIDEBAR OVERLAY BACKDROP
   ============================================================= */
#sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(5, 6, 8, 0.65);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
}

#sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Mobile search toggle button (hidden on desktop) */
.mobile-search-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: var(--border-radius-md);
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-fast);
    flex-shrink: 0;
}
.mobile-search-btn:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

/* Mobile expanded search overlay */
.search-box.mobile-expanded {
    position: fixed !important;
    top: 11px;
    left: 60px;
    right: 15px;
    width: auto !important;
    z-index: 200;
    display: block !important;
}

/* =============================================================
   BREAKPOINT 1: max-width 1200px — Large tablet / small laptop
   ============================================================= */
@media (max-width: 1200px) {
    .page-container {
        padding: 24px;
        gap: 24px;
    }

    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 16px;
    }

    .search-box {
        width: 220px;
    }
}

/* =============================================================
   BREAKPOINT 2: max-width 1024px — iPad Landscape / small laptop
   ============================================================= */
@media (max-width: 1024px) {
    /* Auto-collapse sidebar to icon mode */
    #sidebar {
        width: var(--sidebar-collapsed-width);
    }

    #sidebar .sidebar-wrapper {
        padding: 20px 8px;
    }

    #sidebar .brand-name {
        opacity: 0;
        pointer-events: none;
        width: 0;
        height: 0;
        overflow: hidden;
    }

    #sidebar .sidebar-brand {
        justify-content: center;
        padding: 10px 0 25px 0;
    }

    #sidebar .menu-item a {
        justify-content: center;
        padding: 12px 0;
        gap: 0;
    }

    #sidebar .menu-item a span {
        display: none;
    }

    #sidebar .submenu {
        display: none !important;
    }

    #sidebar .menu-item a .chevron-icon {
        display: none;
    }

    #sidebar .menu-section {
        opacity: 0;
        height: 0;
        padding: 0;
        overflow: hidden;
    }

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

    .page-container {
        padding: 20px;
        gap: 20px;
    }

    .metrics-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
    }

    .search-box {
        width: 200px;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .card-header {
        padding: 16px 20px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .card-body {
        padding: 20px;
    }
}

/* =============================================================
   BREAKPOINT 3: max-width 768px — iPad Portrait / Large Mobile
   ============================================================= */
@media (max-width: 768px) {
    /* Sidebar: off-canvas overlay drawer, resets icon-mode */
    #sidebar {
        width: var(--sidebar-width);
        transform: translateX(-100%);
        transition: transform var(--transition-normal), width var(--transition-normal);
    }

    #sidebar .sidebar-wrapper {
        padding: 20px 15px;
    }

    #sidebar .sidebar-brand {
        justify-content: flex-start;
        padding: 10px 8px 25px 8px;
    }

    #sidebar .brand-name {
        opacity: 1 !important;
        pointer-events: auto !important;
        width: auto !important;
        height: auto !important;
        overflow: visible !important;
    }

    #sidebar .menu-item a {
        justify-content: flex-start !important;
        padding: 12px 14px !important;
        gap: 15px !important;
    }

    #sidebar .menu-item a span {
        display: inline !important;
    }

    #sidebar .menu-item a .chevron-icon {
        display: block !important;
    }

    #sidebar .menu-section {
        opacity: 1 !important;
        height: auto !important;
        padding: 15px 10px 5px 10px !important;
        overflow: visible !important;
    }

    /* Override submenu hide from 1024px */
    #sidebar .submenu {
        display: block !important;
    }

    /* Mobile open state */
    #sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Show the backdrop overlay */
    #sidebar-backdrop {
        display: block;
    }

    /* Main content: full width, no margin */
    #main-content {
        margin-left: 0 !important;
    }

    /* Navbar */
    #top-navbar {
        padding: 0 15px;
        height: 60px;
        gap: 8px;
    }

    .navbar-left {
        gap: 8px;
        flex: 1;
        min-width: 0;
    }

    /* Hide desktop search box, show mobile toggle */
    .search-box {
        display: none;
    }

    .mobile-search-btn {
        display: flex;
    }

    /* Currency: hide label text */
    .currency-widget > span:first-child {
        display: none;
    }

    .currency-widget {
        padding: 5px 8px;
        font-size: 0.78rem;
    }

    /* Hide username text */
    .user-info-text {
        display: none;
    }

    .navbar-right {
        gap: 8px;
    }

    /* Page layout */
    .page-container {
        padding: 15px;
        gap: 15px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-action-area {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .page-title {
        font-size: 1.35rem;
    }

    .page-subtitle {
        font-size: 0.85rem;
    }

    /* Metrics: 2 columns */
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .metric-card {
        padding: 18px;
    }

    .metric-value {
        font-size: 1.5rem;
    }

    /* Cards */
    .card-header {
        padding: 14px 16px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .card-title {
        font-size: 1rem;
    }

    .card-body {
        padding: 15px;
    }

    /* Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-modern th,
    .table-modern td {
        padding: 12px 14px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    /* Modals */
    .modal-card {
        width: 95%;
        max-height: 95vh;
    }

    .modal-body {
        max-height: calc(95vh - 140px);
    }

    /* Invoice grid: single column */
    .invoice-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Pagination */
    .pagination-container {
        padding: 14px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .pagination-controls {
        width: 100%;
        justify-content: space-between;
    }

    /* Toasts to top-center on mobile */
    .toast-container {
        bottom: auto;
        top: 70px;
        right: 15px;
        left: 15px;
    }

    .toast {
        min-width: unset;
        width: 100%;
    }
}

/* =============================================================
   BREAKPOINT 4: max-width 640px — Large phone
   ============================================================= */
@media (max-width: 640px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .metric-card {
        padding: 15px;
        gap: 10px;
    }

    .metric-icon {
        width: 36px;
        height: 36px;
    }

    .metric-value {
        font-size: 1.3rem;
    }

    .metric-label {
        font-size: 0.72rem;
    }

    .table-modern th,
    .table-modern td {
        padding: 10px 12px;
        font-size: 0.82rem;
    }

    /* Modals: sheet-style from bottom */
    .modal-card {
        width: 100%;
        max-width: 100%;
        border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        max-height: 92vh;
        transform: translateY(40px) !important;
    }

    .modal-overlay.active .modal-card {
        transform: translateY(0) !important;
    }

    /* Keep receipt modal as centered panel */
    #receipt-preview-modal .modal-card {
        position: relative;
        bottom: auto;
        border-radius: var(--border-radius-lg);
        transform: translateY(-20px) !important;
        max-height: 90vh;
        width: 95%;
    }

    #receipt-preview-modal.active .modal-card {
        transform: translateY(0) !important;
    }

    .modal-body {
        max-height: calc(92vh - 130px);
        padding: 16px;
    }

    .modal-header,
    .modal-footer {
        padding: 14px 16px;
    }

    .form-group {
        margin-bottom: 15px;
    }

    .form-control {
        padding: 10px 13px;
        font-size: 0.87rem;
    }

    .page-container {
        padding: 12px;
        gap: 12px;
    }

    .page-title {
        font-size: 1.2rem;
    }
}

/* =============================================================
   BREAKPOINT 5: max-width 480px — Standard mobile
   ============================================================= */
@media (max-width: 480px) {
    #sidebar {
        width: 270px;
    }

    #top-navbar {
        padding: 0 12px;
        height: 56px;
    }

    /* Metrics: single column, horizontal card layout */
    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .metric-card {
        flex-direction: row;
        align-items: center;
        padding: 14px 16px;
        gap: 16px;
    }

    .metric-header {
        order: 1;
        flex-shrink: 0;
    }

    .metric-card > div:not(.metric-header) {
        order: 2;
        flex: 1;
    }

    .metric-trend {
        display: none;
    }

    .metric-value {
        font-size: 1.4rem;
        margin-bottom: 2px;
    }

    .metric-label {
        font-size: 0.7rem;
    }

    /* Action buttons stack */
    .header-action-area {
        flex-direction: column;
    }

    .header-action-area .btn {
        width: 100%;
        flex: unset;
        justify-content: center;
    }

    /* Sticky last column for actions */
    .table-modern td:last-child,
    .table-modern th:last-child {
        position: sticky;
        right: 0;
        background-color: var(--surface-card);
        border-left: 1px solid var(--border-color);
        box-shadow: -2px 0 6px rgba(0,0,0,0.06);
        z-index: 2;
    }

    .table-modern th:last-child {
        background-color: var(--bg-secondary);
    }

    .card-body {
        padding: 12px;
    }

    .page-title {
        font-size: 1.1rem;
        letter-spacing: -0.3px;
    }

    .page-subtitle {
        font-size: 0.8rem;
    }

    .badge {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
}

/* =============================================================
   BREAKPOINT 6: max-width 360px — Small mobile (Galaxy A, iPhone SE)
   ============================================================= */
@media (max-width: 360px) {
    #sidebar {
        width: 255px;
    }

    .page-container {
        padding: 10px;
        gap: 10px;
    }

    #top-navbar {
        padding: 0 10px;
    }

    .currency-widget {
        display: none;
    }

    .page-title {
        font-size: 1rem;
    }

    .table-modern th,
    .table-modern td {
        padding: 8px 10px;
        font-size: 0.78rem;
    }

    .btn {
        padding: 8px 12px;
        font-size: 0.82rem;
    }

    .metric-card {
        padding: 12px 14px;
    }

    .metric-value {
        font-size: 1.2rem;
    }

    .modal-header,
    .modal-footer {
        padding: 12px 14px;
    }

    .modal-body {
        padding: 14px;
    }
}

/* =============================================================
   RESPONSIVE UTILITY CLASSES
   ============================================================= */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
}
@media (min-width: 769px) {
    .show-mobile-only { display: none !important; }
}
@media (max-width: 480px) {
    .hide-sm { display: none !important; }
}

/* Card-style table for smallest screens */
@media (max-width: 480px) {
    .table-card-mode { display: block; }
    .table-card-mode thead { display: none; }
    .table-card-mode tbody,
    .table-card-mode tr { display: block; }
    .table-card-mode tr {
        background: var(--surface-card);
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius-md);
        margin-bottom: 10px;
        padding: 12px;
    }
    .table-card-mode td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 6px 0;
        border: none;
        font-size: 0.83rem;
        white-space: normal;
    }
    .table-card-mode td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--text-muted);
        flex-shrink: 0;
        margin-right: 8px;
    }
    .table-card-mode td:last-child {
        position: static !important;
        background: none !important;
        border-left: none !important;
        box-shadow: none !important;
        justify-content: flex-end;
        border-top: 1px solid var(--border-color);
        padding-top: 10px;
        margin-top: 4px;
    }
}




