/* ============================================================
   PHARMACY ERP — Production CSS v2.0
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;600&display=swap');

/* ============================================================
   CSS VARIABLES — LIGHT THEME (default)
   ============================================================ */
:root {
    --bg-base: #f0f4f8;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-2: #1e293b;
    --bg-hover: #f8fafc;
    --bg-input: #f8fafc;
    --bg-modal: rgba(15, 23, 42, 0.65);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;
    --text-sidebar: #cbd5e1;

    --border: #e2e8f0;
    --border-focus: #0ea5e9;

    --accent-blue: #0ea5e9;
    --accent-green: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-purple: #8b5cf6;
    --accent-indigo: #6366f1;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .10);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, .14);
    --shadow-xl: 0 20px 48px rgba(0, 0, 0, .18);

    --radius-sm: .5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    --radius-xl: 2rem;
    --radius-full: 9999px;

    --sidebar-w: 260px;
    --header-h: 70px;
    --transition: all .22s cubic-bezier(.4, 0, .2, 1);
}

/* ============================================================
   DARK THEME
   ============================================================ */
[data-theme="dark"] {
    --bg-base: #0d1117;
    --bg-card: #161b22;
    --bg-sidebar: #090c11;
    --bg-sidebar-2: #0d1117;
    --bg-hover: #1c2230;
    --bg-input: #1c2230;
    --bg-modal: rgba(0, 0, 0, .80);

    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --text-sidebar: #8b949e;

    --border: #21262d;
    --border-focus: #0ea5e9;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, .6);
    --shadow-xl: 0 20px 48px rgba(0, 0, 0, .7);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background .3s, color .3s;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, .04);
}

.sidebar-brand {
    padding: 1.5rem 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-brand .brand-name {
    font-size: 1.15rem;
    font-weight: 800;
    color: #38bdf8;
    letter-spacing: -.5px;
    display: block;
}

.sidebar-brand .brand-sub {
    font-size: .65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-top: .15rem;
}

.sidebar-nav {
    flex: 1;
    padding: .75rem;
    overflow-y: auto;
}

.nav-section-label {
    font-size: .6rem;
    font-weight: 700;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: .1em;
    padding: .75rem .75rem .35rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .85rem;
    border-radius: var(--radius-md);
    color: var(--text-sidebar);
    font-size: .82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: .15rem;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    user-select: none;
}

.nav-item:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
}

.nav-item.active {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: #fff;
    box-shadow: 0 4px 14px rgba(14, 165, 233, .35);
    font-weight: 600;
}

.nav-item i {
    width: 18px;
    text-align: center;
    font-size: .9rem;
    opacity: .8;
}

.nav-item.active i {
    opacity: 1;
}

.nav-badge {
    margin-left: auto;
    background: var(--accent-rose);
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    padding: .1rem .4rem;
    border-radius: 99px;
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem .75rem;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.user-card {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .75rem;
    border-radius: var(--radius-md);
    margin-bottom: .5rem;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .75rem;
    font-weight: 800;
    flex-shrink: 0;
}

.user-name {
    font-size: .8rem;
    font-weight: 700;
    color: #e2e8f0;
}

.user-role {
    font-size: .65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .07em;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    padding: .6rem;
    border-radius: var(--radius-md);
    background: rgba(244, 63, 94, .08);
    color: #f43f5e;
    border: 1px solid rgba(244, 63, 94, .15);
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(244, 63, 94, .18);
}

/* ============================================================
   MAIN AREA
   ============================================================ */
.main-area {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
    height: var(--header-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm);
}

.header-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -.3px;
}

.header-sub {
    font-size: .7rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: .1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.header-datetime {
    text-align: right;
}

.header-date {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-time {
    font-size: .7rem;
    color: var(--text-muted);
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    font-size: .9rem;
}

.icon-btn:hover {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

.notif-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: var(--accent-rose);
    color: #fff;
    font-size: .6rem;
    font-weight: 800;
    border-radius: 99px;
    border: 2px solid var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   CONTENT AREA
   ============================================================ */
.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* MODULE TABS */
.module-tab {
    display: none;
}

.module-tab.active {
    display: block;
    animation: fadeIn .22s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: .95rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -.2px;
}

.card-sub {
    font-size: .7rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: .15rem;
}

.card-body {
    padding: 1.5rem;
}

/* STAT CARDS */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.4rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 60%, rgba(14, 165, 233, .04));
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-blue);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    transition: var(--transition);
}

.stat-card:hover .stat-icon {
    transform: scale(1.1);
}

.stat-card.sortable-ghost {
    opacity: 0.4;
    background: var(--bg-hover);
    border: 2px dashed var(--accent-blue);
    transform: scale(0.98);
}

.stat-label {
    font-size: .68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: -1px;
    line-height: 1;
    margin-top: .2rem;
}

.stat-change {
    font-size: .68rem;
    color: var(--text-muted);
    margin-top: .2rem;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: .9rem 1rem;
    text-align: left;
    white-space: nowrap;
}

thead th:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

thead th:last-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg-hover);
}

tbody td {
    padding: .85rem 1rem;
    font-size: .82rem;
    color: var(--text-primary);
    vertical-align: middle;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .6rem 1.2rem;
    border-radius: var(--radius-md);
    font-size: .78rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    user-select: none;
}

.btn:active {
    transform: scale(.97);
}

.btn-primary {
    background: var(--accent-blue);
    color: #fff;
    box-shadow: 0 4px 14px rgba(14, 165, 233, .3);
}

.btn-primary:hover {
    background: #0284c7;
    box-shadow: 0 6px 20px rgba(14, 165, 233, .4);
}

.btn-success {
    background: var(--accent-green);
    color: #fff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, .3);
}

.btn-success:hover {
    filter: brightness(1.1);
}

.btn-warning {
    background: var(--accent-amber);
    color: #fff;
}

.btn-warning:hover {
    filter: brightness(1.1);
}

.btn-danger {
    background: var(--accent-rose);
    color: #fff;
    box-shadow: 0 4px 14px rgba(244, 63, 94, .25);
}

.btn-danger:hover {
    filter: brightness(1.1);
}

.btn-ghost {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--border);
}

.btn-dark {
    background: var(--text-primary);
    color: var(--bg-card);
}

.btn-dark:hover {
    opacity: .87;
}

.btn-sm {
    padding: .4rem .8rem;
    font-size: .72rem;
}

.btn-lg {
    padding: .85rem 2rem;
    font-size: .9rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* ============================================================
   FORMS & INPUTS
   ============================================================ */
.form-group {
    margin-bottom: 1.1rem;
}

.form-label {
    display: block;
    font-size: .72rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .07em;
    margin-bottom: .4rem;
}

.form-control {
    width: 100%;
    padding: .7rem 1rem;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: .85rem;
    font-family: inherit;
    font-weight: 500;
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, .15);
    background: var(--bg-card);
}

.form-control::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-grid {
    display: grid;
    gap: 1rem;
}

.form-grid-2 {
    grid-template-columns: 1fr 1fr;
}

.form-grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .22rem .6rem;
    border-radius: 99px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .04em;
}

.badge-blue {
    background: rgba(14, 165, 233, .12);
    color: #0ea5e9;
}

.badge-green {
    background: rgba(16, 185, 129, .12);
    color: #10b981;
}

.badge-amber {
    background: rgba(245, 158, 11, .12);
    color: #d97706;
}

.badge-rose {
    background: rgba(244, 63, 94, .12);
    color: #f43f5e;
}

.badge-purple {
    background: rgba(139, 92, 246, .12);
    color: #8b5cf6;
}

.badge-gray {
    background: var(--bg-input);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-modal);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    transform: translateY(20px) scale(.97);
    transition: var(--transition);
    border: 1px solid var(--border);
}

.modal-overlay.open .modal {
    transform: none;
}

.modal-lg {
    max-width: 760px;
}

.modal-xl {
    max-width: 1000px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -.3px;
}

.modal-body {
    padding: 1.75rem;
}

.modal-footer {
    padding: 1rem 1.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
}

.btn-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    transition: var(--transition);
}

.btn-close:hover {
    background: var(--accent-rose);
    color: #fff;
    border-color: var(--accent-rose);
}

/* ============================================================
   NOTIFICATION DRAWER
   ============================================================ */
.notif-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 340px;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    z-index: 150;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
    display: flex;
    flex-direction: column;
}

.notif-drawer.open {
    transform: none;
}

.notif-drawer-header {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.notif-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.notif-item {
    position: relative;
    padding: .85rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    margin-bottom: .5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: flex-start;
    gap: .75rem;
}

.notif-item.low-stock {
    background: rgba(244, 63, 94, .06);
    border-color: rgba(244, 63, 94, .15);
}

.notif-item.expiry {
    background: rgba(245, 158, 11, .06);
    border-color: rgba(245, 158, 11, .15);
}

.notif-item:hover {
    transform: translateX(-3px);
}

.notif-dismiss {
    position: absolute;
    top: .5rem;
    right: .5rem;
    width: 22px;
    height: 22px;
    border-radius: 99px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .65rem;
    opacity: 0;
    transition: var(--transition);
}

.notif-item:hover .notif-dismiss {
    opacity: 1;
}

.notif-dismiss:hover {
    background: var(--accent-green);
    color: #fff;
    border-color: var(--accent-green);
}

/* ============================================================
   POS MODULE
   ============================================================ */
.pos-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 1.5rem;
    height: calc(100vh - var(--header-h) - 4rem);
}

.pos-left {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
}

.pos-right {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.search-wrapper {
    position: relative;
}

.search-wrapper i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    padding: .75rem 1rem .75rem 2.75rem;
}

.search-dropdown {
    position: absolute;
    top: calc(100% + .25rem);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    max-height: 380px;
    overflow-y: auto;
    display: none;
}

.search-dropdown.visible {
    display: block;
}

.search-result-item {
    padding: .9rem 1.1rem;
    display: flex;
    align-items: center;
    gap: .85rem;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(14, 165, 233, .06);
}

.cart-table-wrap {
    flex: 1;
    overflow-y: auto;
}

.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
    gap: .75rem;
}

.cart-empty i {
    font-size: 2.5rem;
    opacity: .3;
}

/* SUMMARY PANEL */
.summary-panel {
    background: var(--bg-sidebar);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-shrink: 0;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-label {
    font-size: .72rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .07em;
}

.summary-value {
    font-size: .9rem;
    font-weight: 700;
    color: #94a3b8;
}

.summary-divider {
    height: 1px;
    background: rgba(255, 255, 255, .06);
}

.summary-total .summary-label {
    color: #7dd3fc;
}

.summary-total .summary-value {
    font-size: 2.2rem;
    font-weight: 900;
    color: #38bdf8;
    letter-spacing: -1px;
    line-height: 1;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: .85rem 1.1rem;
    border-radius: var(--radius-md);
    font-size: .82rem;
    font-weight: 500;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .6rem;
}

.alert-info {
    background: rgba(14, 165, 233, .1);
    color: #0ea5e9;
    border: 1px solid rgba(14, 165, 233, .2);
}

.alert-success {
    background: rgba(16, 185, 129, .1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, .2);
}

.alert-warning {
    background: rgba(245, 158, 11, .1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, .2);
}

.alert-danger {
    background: rgba(244, 63, 94, .1);
    color: #f43f5e;
    border: 1px solid rgba(244, 63, 94, .2);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: .85rem 1.2rem;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: .7rem;
    font-size: .82rem;
    font-weight: 600;
    pointer-events: all;
    animation: slideIn .28s ease;
    min-width: 280px;
}

.toast.success {
    border-left: 4px solid var(--accent-green);
}

.toast.error {
    border-left: 4px solid var(--accent-rose);
}

.toast.warning {
    border-left: 4px solid var(--accent-amber);
}

.toast.info {
    border-left: 4px solid var(--accent-blue);
}

@keyframes slideIn {
    from {
        transform: translateX(110%);
        opacity: 0;
    }

    to {
        transform: none;
        opacity: 1;
    }
}

/* ============================================================
   CHARTS
   ============================================================ */
.chart-container {
    position: relative;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0c4a6e 100%);
}

.login-left {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, .06);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-xl);
}

.login-logo {
    font-size: 1.5rem;
    font-weight: 900;
    color: #38bdf8;
    letter-spacing: -.5px;
    margin-bottom: .25rem;
}

.login-tagline {
    font-size: .78rem;
    color: #64748b;
    margin-bottom: 2rem;
}

.login-input {
    width: 100%;
    padding: .8rem 1rem;
    background: rgba(255, 255, 255, .08);
    border: 1.5px solid rgba(255, 255, 255, .12);
    border-radius: var(--radius-md);
    color: #e2e8f0;
    font-family: inherit;
    font-size: .88rem;
    outline: none;
    transition: var(--transition);
    margin-bottom: .9rem;
}

.login-input:focus {
    border-color: #38bdf8;
    background: rgba(255, 255, 255, .12);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, .18);
}

.login-input::placeholder {
    color: #475569;
}

.login-label {
    display: block;
    font-size: .72rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: .4rem;
}

.btn-login {
    width: 100%;
    padding: .95rem;
    margin-top: .5rem;
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: #fff;
    font-size: .9rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 6px 20px rgba(14, 165, 233, .4);
    letter-spacing: .03em;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(14, 165, 233, .55);
}

.login-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    background: linear-gradient(135deg, rgba(14, 165, 233, .08), rgba(139, 92, 246, .08));
}

/* ============================================================
   FILTERS ROW
   ============================================================ */
.filters-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.filters-row .form-control {
    width: auto;
    min-width: 150px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    opacity: .25;
    margin-bottom: 1rem;
    display: block;
}

.empty-state h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: .35rem;
}

.empty-state p {
    font-size: .82rem;
}

/* ============================================================
   THEME TOGGLE
   ============================================================ */
.theme-toggle {
    width: 42px;
    height: 24px;
    border-radius: 99px;
    background: var(--border);
    position: relative;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
    display: flex;
    align-items: center;
    padding: 3px;
}

.theme-toggle.on {
    background: var(--accent-blue);
}

.theme-knob {
    width: 18px;
    height: 18px;
    border-radius: 99px;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.theme-toggle.on .theme-knob {
    transform: translateX(18px);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    :root {
        --sidebar-w: 220px;
    }

    .pos-grid {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
    }

    .pos-left {
        overflow: visible;
        height: auto;
    }

    .pos-right {
        min-height: auto;
        overflow: visible;
        margin-top: 1rem;
    }

    .form-grid-3 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-w: 0px;
    }

    .sidebar {
        display: none;
    }

    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr;
    }

    .login-right {
        display: none;
    }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-sm {
    font-size: .78rem;
}

.text-xs {
    font-size: .7rem;
}

.text-muted {
    color: var(--text-muted);
}

.text-primary-c {
    color: var(--accent-blue);
}

.text-success {
    color: var(--accent-green);
}

.text-warning {
    color: var(--accent-amber);
}

.text-danger {
    color: var(--accent-rose);
}

.font-bold {
    font-weight: 700;
}

.font-black {
    font-weight: 900;
}

.d-flex {
    display: flex;
}

.align-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: .5rem;
}

.gap-2 {
    gap: 1rem;
}

.gap-3 {
    gap: 1.5rem;
}

.mt-1 {
    margin-top: .5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mb-1 {
    margin-bottom: .5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.p-0 {
    padding: 0;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.w-full {
    width: 100%;
}

.mono {
    font-family: 'JetBrains Mono', monospace;
}

.pill {
    border-radius: 99px !important;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 1rem 0;
}

.hidden {
    display: none !important;
}

/* ============================================================
   AI ASSISTANT STYLES
   ============================================================ */
/* ============================================================
   AI ASSISTANT STYLES - Premium Redesign
   ============================================================ */
.ai-assistant-layout {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 1.5rem;
    align-items: start;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-assistant-layout.editor-active {
    grid-template-columns: 1fr;
}

.ai-invoice-parser-card {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-card);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    height: 580px;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.3s ease;
}

.ai-invoice-parser-card:hover {
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.25);
}

.ai-invoice-dropzone {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
    text-align: center;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    margin: 1.5rem;
    background: rgba(255, 255, 255, 0.01);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-invoice-dropzone:hover {
    border-color: var(--accent-blue);
    background: rgba(14, 165, 233, 0.03);
    box-shadow: inset 0 0 20px rgba(14, 165, 233, 0.05);
}

.dropzone-icon {
    font-size: 3.5rem;
    color: var(--accent-blue);
    margin-bottom: 1.25rem;
    opacity: 0.85;
    transition: transform 0.3s ease;
}

.ai-invoice-dropzone:hover .dropzone-icon {
    transform: translateY(-5px);
}

.ai-invoice-dropzone h3 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.ai-invoice-dropzone p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 380px;
    margin-bottom: 1.25rem;
}

.ai-invoice-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ai-chat-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-card);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.3s ease;
}

.ai-chat-card:hover {
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.25);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: radial-gradient(circle at top left, var(--bg-body), var(--bg-card));
    scroll-behavior: smooth;
}

.ai-message {
    display: flex;
    gap: 1rem;
    max-width: 80%;
    align-self: flex-start;
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.ai-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-message.system {
    align-self: center;
    max-width: 90%;
    margin: 1rem 0;
}

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.15), rgba(14, 165, 233, 0.05));
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.15);
    border: 1px solid rgba(14, 165, 233, 0.2);
    transition: transform 0.2s ease;
}

.ai-message.user .message-avatar {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05));
    color: var(--accent-green);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.message-avatar:hover {
    transform: scale(1.08) rotate(5deg);
}

.message-bubble {
    padding: 1rem 1.25rem;
    border-radius: 18px;
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    word-break: break-word;
    position: relative;
    transition: transform 0.2s ease;
}

.ai-message.user .message-bubble {
    background: linear-gradient(135deg, var(--accent-blue) 0%, #0284c7 100%);
    color: #fff;
    border: none;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.25);
}

.ai-message.system .message-bubble {
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    border: 1px dashed var(--border);
}

.ai-chat-input-area {
    padding: 1.25rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ai-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.ai-chat-suggestions button {
    border-radius: 99px;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    background: var(--bg-body);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.ai-chat-suggestions button:hover {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
}

.ai-upload-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: rgba(14, 165, 233, 0.08);
    border: 1px dashed rgba(14, 165, 233, 0.3);
    border-radius: 10px;
    font-size: 0.78rem;
    color: #0ea5e9;
    font-weight: 700;
    animation: fadeInUp 0.2s ease;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    background: rgba(14, 165, 233, 0.05);
    transform: translateY(-1px);
}

.btn-close-sm {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.btn-close-sm:hover {
    color: var(--accent-rose);
}

.ai-invoice-preview-card {
    animation: fadeInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.15);
    background: var(--bg-card);
    overflow: hidden;
}

.ai-loader {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.ai-loader span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: ai-bounce 1.4s infinite ease-in-out both;
}

.ai-loader span:nth-child(1) { animation-delay: -0.32s; }
.ai-loader span:nth-child(2) { animation-delay: -0.16s; }

/* Custom markdown rendering in chat bubble */
.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.8rem;
}

.message-bubble th, .message-bubble td {
    border: 1px solid var(--border);
    padding: 0.5rem;
    text-align: left;
}

.message-bubble th {
    background: var(--bg-body);
    font-weight: 700;
}

.message-bubble pre {
    background: rgba(0,0,0,0.15);
    padding: 0.75rem;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    margin: 0.5rem 0;
}

@keyframes ai-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* AI Invoice Table Inputs Styling */
#ai-inv-tbody td {
    padding: 0.4rem 0.5rem;
}
#ai-inv-tbody td .form-control {
    padding: 0.35rem 0.6rem;
    height: auto;
    font-size: 0.8rem;
    border-radius: 6px;
    border-color: var(--border);
}
#ai-inv-tbody td .form-control:focus {
    border-color: var(--accent-blue);
    background: var(--bg-card);
}

.mobile-menu-toggle,
.sidebar-close-btn {
    display: none;
}

/* ============================================================
   RESPONSIVE LAYOUTS & MEDIA QUERIES
   ============================================================ */

/* Small desktop / tablet view */
@media (max-width: 1024px) {
    :root {
        --sidebar-w: 260px;
    }
    
    .sidebar {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        z-index: 10000 !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        box-shadow: var(--shadow-xl);
        display: flex !important;
    }
    
    .sidebar.open {
        transform: translateX(0) !important;
    }
    
    .sidebar-close-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid rgba(255, 255, 255, 0.15);
        color: var(--text-sidebar);
        width: 32px;
        height: 32px;
        border-radius: var(--radius-sm);
        cursor: pointer;
        transition: var(--transition);
    }
    
    .sidebar-close-btn:hover {
        background: rgba(255, 255, 255, 0.15);
        color: #fff;
    }
    
    .mobile-menu-toggle {
        display: flex !important;
    }
    
    .main-area {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .app-header {
        padding: 0 1.5rem;
    }
    
    .content-area {
        padding: 1.5rem;
    }
    
    /* POS Responsiveness */
    .pos-grid {
        grid-template-columns: 1fr !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    .pos-left, .pos-right {
        overflow: visible !important;
        height: auto !important;
    }
    
    /* Grid adjustments */
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .grid-3 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* AI Assistant */
    .ai-assistant-layout {
        grid-template-columns: 1fr !important;
    }
}

/* Mobile Devices */
@media (max-width: 768px) {
    html {
        font-size: 13px;
    }
    
    .app-header {
        padding: 0 1rem;
    }
    
    .header-sub {
        display: none; /* Hide subtitle to preserve space */
    }
    
    .header-datetime {
        display: none; /* Hide clock on mobile header to avoid overlap */
    }
    
    .content-area {
        padding: 1rem;
    }
    
    /* Card tweaks */
    .card-header {
        padding: 1rem 1.25rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .card-header > div {
        width: 100%;
    }
    
    .card-header .d-flex, 
    .card-header .filters-row {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .card-header .form-control,
    .card-header .btn {
        flex: 1 1 auto;
        width: auto;
    }
    
    /* Grids to single column */
    .grid-4, .grid-3, .grid-2 {
        grid-template-columns: 1fr !important;
    }
    
    .form-grid-3, .form-grid-2 {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }
    
    /* Modals */
    .modal {
        max-width: 95% !important;
        margin: 0 auto;
        border-radius: var(--radius-lg);
    }
    
    .modal-header, .modal-footer {
        padding: 1rem 1.25rem;
    }
    
    .modal-body {
        padding: 1.25rem;
    }
    
    /* Tables scrollability hint */
    .table-wrap {
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        margin-bottom: 1rem;
    }
    
    /* Dashboard widget flow */
    #dash-top-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* AI message bubble max width */
    .ai-message {
        max-width: 95%;
    }
    
    /* POS payment details */
    .pos-summary-wrap {
        padding: 1rem !important;
    }
    
    .pos-bill-details {
        margin-top: 1rem;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .header-title {
        font-size: 1rem;
    }
    
    .icon-btn {
        width: 34px;
        height: 34px;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
    }
    
    .toast {
        width: 90% !important;
        left: 5% !important;
        bottom: 10px !important;
    }
}

/* POS Search Results keyboard selection highlight style */
.search-result-item.highlighted {
    background: rgba(14, 165, 233, 0.12) !important;
    border-left: 3px solid var(--accent-blue) !important;
}