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

:root {
    /* Ayurvedic Premium Palette */
    --primary: #01a833;
    /* Ayurvedic Leaf Green */
    --primary-hover: #047857;
    --primary-soft: #f0fdf4;
    --secondary: #10b981;
    --accent: #34d399;

    /* Functional Colors */
    --success: #10b981;
    --warning: #fbbf24;
    --danger: #f43f5e;
    --info: #10b981;

    /* Elegant Neutrals */
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --border: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    /* Professional Sidebar */
    --sidebar-bg: #064e3b;
    --sidebar-text: #ecfdf5;
    --sidebar-hover: #065f46;
    --sidebar-active: #10b981;

    /* Dimensions & Transitions */
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
    --header-height: 72px;
    --border-radius: 0px !important;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Premium Shadows */
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 10px 15px -3px rgb(0 0 0 / 0.04), 0 4px 6px -4px rgb(0 0 0 / 0.04);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.05), 0 8px 10px -6px rgb(0 0 0 / 0.05);
    --shadow-xl: 0 25px 50px -12px rgb(0 0 0 / 0.1);

    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-blur: blur(12px);

    /* Animations */
    --animation-pulse: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    --animation-skeleton: skeleton-loading 1.2s linear infinite alternate;
}

/* Mobile Overrides (Strictly max-width: 768px) */
@media (max-width: 768px) {
    :root {
        --border-radius: 0px !important;
        --header-height: 60px;
        --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    }
    body {
        font-family: 'Poppins', sans-serif !important;
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

@keyframes skeleton-loading {
    0% { background-color: #f1f5f9; }
    100% { background-color: #e2e8f0; }
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

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

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-left: var(--sidebar-width);
    transition: var(--transition);
}

.app-sidebar.collapsed + .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

/* Sidebar Styling */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    transition: var(--transition);
    z-index: 1000;
    overflow-x: hidden;
}

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

.sidebar-header {
    padding: 15px;
    /* Reduced from 24px for better alignment */
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
    justify-content: flex-start;
}

.app-sidebar.collapsed .sidebar-header {
    padding: 15px 0;
    justify-content: center;
}

.logo-box {
    min-width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    flex-shrink: 0;
}

.brand-name {      
    font-weight: 700;
    font-size: 18px;
    color: white;
    opacity: 1;
    transition: var(--transition);
}

.app-sidebar.collapsed .brand-name {
    opacity: 0;
    pointer-events: none;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
}

.nav-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #6ee7b7;
    margin: 24px 12px 12px;
    font-weight: 600;
    white-space: nowrap;
    transition: var(--transition);
}

.app-sidebar.collapsed .nav-label {
    opacity: 0;
}

.nav-link,
.nav-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    height: 44px;
    /* Uniform height */
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
    color: var(--sidebar-text);
    text-decoration: none;
    cursor: pointer;
    user-select: none;
}

.nav-link i,
.nav-section-header i:not(.chevron) {
    font-size: 18px;
    /* Uniform icon size */
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link span,
.nav-section-header span {
    flex: 1;
}

.nav-link:hover,
.nav-section-header:hover {
    background: var(--sidebar-hover);
    color: white;
}

.nav-link.active {
    background: var(--sidebar-active);
    color: white;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.2);
}

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

/* Header */
.app-header {
    height: var(--header-height);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 900;
}

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

.toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--bg-main);
    color: var(--text-muted);
    border: none;
    transition: var(--transition);
}

.toggle-btn:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: var(--bg-main);
    border-radius: var(--border-radius);
    cursor: pointer;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

/* Main Content */
.content-area {
    padding: 32px;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
}

/* Cards */
.app-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 28px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.app-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: rgba(5, 150, 105, 0.1);
}

/* Dashboard Stats */
.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
    /* Ensure smooth transition if not already covered */
}

.stat-icon {
    width: 64px;
    height: 64px;
    border-radius: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: var(--primary-soft);
    color: var(--primary);
    flex-shrink: 0;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
    display: block;
}

.stat-currency {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-sm);
}

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

.btn-secondary:hover {
    background: var(--primary-soft);
    box-shadow: var(--shadow-sm);
}

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

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

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

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

.btn-light {
    background: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-light:hover {
    background: #e2e8f0;
}

/* Button Loading State */
.btn.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-top: -8px;
    margin-left: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.6s linear infinite;
}

.btn-secondary.is-loading::after {
    border-color: rgba(22, 163, 74, 0.2);
    border-top-color: var(--primary);
}

/* Skeleton Screens */
.skeleton {
    animation: var(--animation-skeleton);
    border-radius: var(--border-radius);
    display: inline-block;
}

.skeleton-text {
    width: 100%;
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-title {
    width: 60%;
    height: 20px;
    margin-bottom: 12px;
}

.skeleton-card {
    background: #f8fafc;
    border-radius: var(--border-radius);
    padding: 24px;
}

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

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    min-height: 44px; /* Standardized height */
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 0 !important;
    outline: none;
    transition: var(--transition);
    background-color: #ffffff;
    font-size: 14px;
    color: var(--text-main);
    display: block;
}

select.form-control {
    appearance: none;
    /* Custom arrow fallback for selects when not using TomSelect */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 14px center;
    background-repeat: no-repeat;
    background-size: 1.25em 1.25em;
    padding-right: 44px !important;
}

.form-control:focus {
    background-color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.08); /* Focus effect */
}

/* Modern Form Grid System */
.modern-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 24px;
    align-items: start;
}

.modern-form-grid .form-group {
    margin-bottom: 0; /* Managed by grid gap */
    width: 100%;
}

/* Responsive Grid */
@media (max-width: 991px) {
    .modern-form-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* Full Width Utility */
.col-span-2 {
    grid-column: span 2;
}

/* Auto-span textareas and large fields if not explicitly marked */
.modern-form-grid textarea,
.modern-form-grid .full-width-field {
    grid-column: span 2;
}

/* Adjustments for tight modern look */
.app-card .modern-form-grid {
    margin-top: 12px;
}

/* Tables */
.table-container {
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
    overflow-x: auto;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.custom-table th {
    background: #f8fafc;
    padding: 18px 24px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.custom-table td {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
}

.custom-table tr:hover,
.table tr:hover {
    background-color: #f9fafb;
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f8fafc;
}

/* Responsive Layout System - Mobile First Logic */
.main-wrapper {
    margin-left: 0;
    padding-bottom: 70px; /* Space for bottom nav on mobile */
    transition: var(--transition);
}

.app-sidebar {
    position: fixed;
    left: calc(-1 * var(--sidebar-width));
    width: var(--sidebar-width) !important;
    height: 100vh;
    z-index: 10000;
    box-shadow: 20px 0 30px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
}

.app-sidebar.show {
    left: 0;
}

@media (min-width: 1025px) {
    .main-wrapper {
        margin-left: var(--sidebar-width);
        padding-bottom: 0;
    }
    .app-sidebar {
        left: 0;
        position: fixed;
        box-shadow: none;
    }
    .app-sidebar.collapsed {
        width: var(--sidebar-collapsed-width) !important;
    }
    .app-sidebar.collapsed + .main-wrapper {
        margin-left: var(--sidebar-collapsed-width);
    }
}

/* Bottom Navigation */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    height: 65px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid var(--border);
    z-index: 5000;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
}

.mobile-nav-item i {
    font-size: 20px;
}

.mobile-nav-item.active {
    color: var(--primary);
}

@media (min-width: 1025px) {
    .mobile-nav {
        display: none;
    }
}

/* Full Screen Modals on Mobile */
@media (max-width: 768px) {
    .modal-dialog {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    .modal-content {
        height: 100% !important;
        border-radius: 0 !important;
    }
    .modal-body {
        max-height: calc(100vh - 70px) !important;
    }
}

/* Responsive Table to Cards */
@media (max-width: 768px) {
    .responsive-table {
        border: none !important;
        background: transparent !important;
        display: block !important;
    }
    .responsive-table thead {
        display: none !important;
    }
    .responsive-table tbody {
        display: block !important;
    }
    .responsive-table tr {
        display: block !important;
        background: white !important;
        margin-bottom: 16px !important;
        padding: 16px !important;
        border: 1px solid var(--border) !important;
        border-radius: 0 !important;
        box-shadow: var(--shadow-sm) !important;
    }
    .responsive-table td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 10px 0 !important;
        border-bottom: 1px solid var(--border) !important;
        font-size: 14px !important;
        text-align: right !important;
    }
    .responsive-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
        text-align: left;
        margin-right: 15px;
    }
    .responsive-table td:last-child {
        border-bottom: none !important;
        justify-content: flex-end !important;
        gap: 8px;
        padding-top: 15px !important;
    }
}

/* Modal Centering Hardware */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 20000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.show { display: flex; }
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    z-index: 19999;
}
.modal-dialog {
    position: relative;
    z-index: 20000;
    margin: 0 !important;
}

.text-primary {
    color: var(--primary) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-main {
    color: var(--text-main) !important;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: var(--border-radius);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-info {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

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

/* Grid Layouts */
.card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

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

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

@media (max-width: 1440px) {
    .card-grid, .grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1200px) {
    .card-grid, .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .card-grid, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

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

/* Utilities */
.gap-12 {
    gap: 12px;
}

.d-flex {
    display: flex;
}

.align-items-center {
    align-items: center;
}

.justify-content-between {
    justify-content: space-between;
}

.flex-column {
    flex-direction: column;
}

.font-14 {
    font-size: 14px;
}

.font-600 {
    font-weight: 600;
}

.w-100 {
    width: 100%;
}

.m-b-32 {
    margin-bottom: 32px;
}

/* Page Header */
.page-title-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.page-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.breadcrumb {
    font-size: 14px;
    color: var(--text-muted);
}

/* Login Page Specific Styles */
.login-wrapper {
    display: flex;
    min-height: 100vh;
    background: #ffffff;
}

.login-branding {
    flex: 1.2;
    position: relative;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 80px;
    color: white;
    overflow: hidden;
}

.login-branding::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('../images/login_bg.png');
    background-size: cover;
    background-position: center;
    opacity: 0.15;
    z-index: 1;
}

.login-branding-content {
    position: relative;
    z-index: 2;
    max-width: 500px;
}

.login-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 32px;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
}

.login-branding h1 {
    font-size: 36px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 24px;
    letter-spacing: -0.02em;
}

.login-branding p {
    font-size: 18px;
    opacity: 0.9;
    line-height: 1.6;
}

.login-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
    padding: 40px;
}

.login-card {
    width: 100%;
    max-width: 440px;
    animation: fadeInScale 0.5s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.login-card h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-main);
    text-align: center;
}

.login-card p.subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 15px;
    margin-bottom: 32px;
}

.login-footer {
    position: absolute;
    bottom: 32px;
    left: 0;
    right: 0;
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
}

@media (max-width: 1024px) {
    .login-wrapper {
        flex-direction: column;
    }

    .login-branding {
        padding: 60px 40px;
        flex: none;
    }

    .login-branding h1 {
        font-size: 28px;
    }

    .login-branding p {
        font-size: 16px;
    }

    .login-form-side {
        padding: 40px 20px;
    }

    .login-footer {
        position: static;
        margin-top: 40px;
    }
}

/* Sidebar Reorganization & Submenus */
.nav-section {
    margin-bottom: 2px;
}

.nav-section-header {
    margin: 0 12px;
    padding: 0 16px;
    color: var(--sidebar-text);
}

.nav-section-header i.chevron {
    font-size: 10px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.5;
}

.nav-section.open .nav-section-header i.chevron {
    transform: rotate(180deg);
}

.nav-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-section.open .nav-section-content {
    max-height: 500px;
}

.nav-section-content .nav-link {
    height: 38px;
    margin: 2px 12px 2px 28px;
    padding: 0 16px;
    font-size: 13.5px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.7);
}

.nav-section-content .nav-link i {
    font-size: 16px;
}

.nav-section-content .nav-link:hover,
.nav-section-content .nav-link.active {
    color: white;
    opacity: 1;
}

/* Section Labels (as per Point 5) */
.nav-section-label {
    padding: 24px 24px 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.4);
    display: block;
}

/* Sidebar Collapsed Overrides */
.app-sidebar.collapsed .nav-section-header span,
.app-sidebar.collapsed .nav-section-header i.chevron,
.app-sidebar.collapsed .nav-link span,
.app-sidebar.collapsed .nav-section-label {
    display: none;
}

.app-sidebar.collapsed .nav-link,
.app-sidebar.collapsed .nav-section-header {
    justify-content: center;
    padding: 0;
}

.app-sidebar.collapsed .nav-section-content {
    display: none;
}

.nav-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 12px 20px;
}

/* Sidebar Transitions */
.app-sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

@media (max-width: 1024px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }
}

/* Modal System */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    /* Removed blur for clarity */
    backdrop-filter: none;
    transition: opacity 0.3s ease;
}

.modal-dialog {
    position: relative;
    width: 90%;
    max-width: 1100px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-xl);
    z-index: 20001;
    animation: modalSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-dialog.modal-lg {
    max-width: 1300px;
}

@media (min-width: 1600px) {
    .modal-dialog {
        max-width: 1200px;
    }

    .modal-dialog.modal-lg {
        max-width: 1400px;
    }
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: 80vh;
    flex: 1;
}

.card-grid-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 32px;
}

/* Responsive Dashboard & Grids */
@media (max-width: 1200px) {
    .content-area {
        padding: 24px 16px;
    }
}

@media (max-width: 1024px) {
    .card-grid-container {
        grid-template-columns: 1fr !important;
    }
}

/* Doctor Profile Responsive Grid */
.doctor-profile-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 32px;
}

@media (max-width: 1200px) {
    .doctor-profile-grid {
        grid-template-columns: 1fr;
    }

    .doctor-profile-grid>div:first-child {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }
}

@media (max-width: 768px) {
    .doctor-profile-grid>div:first-child {
        grid-template-columns: 1fr;
    }

    .profile-stats-grid {
        grid-template-columns: 1fr !important;
    }
}

.profile-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Global App Form Grid (Modern 2-Column with Side) */
.app-form-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 32px;
    align-items: start;
}

.app-form-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.app-form-side {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.sticky-sidebar {
    position: sticky;
    top: calc(var(--header-height) + 32px);
    z-index: 10;
}

@media (max-width: 991px) {
    .app-form-grid {
        grid-template-columns: 1fr;
    }
    .sticky-sidebar {
        position: static;
    }
}

/* Modal Form Grid Layout */

/* Mobile Modals */
@media (max-width: 768px) {
    .modal {
        padding: 0;
    }

    .modal-dialog {
        max-width: 100%;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .modal-body {
        max-height: calc(100vh - 70px);
    }
}

/* Prescription History Specific UI */
.prescription-index-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.search-filter-bar {
    display: flex;
    gap: 12px;
    flex: 1;
    min-width: 300px;
}

.view-toggle {
    display: flex;
    background: #e2e8f0;
    padding: 4px;
    border-radius: var(--border-radius);
    gap: 4px;
}

.view-toggle-btn {
    border: none;
    background: transparent;
    padding: 6px 12px;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    transition: var(--transition);
}

.view-toggle-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Avatars */
.patient-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius);
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    margin-right: 10px;
}

/* Status Badges (Soft) */
.badge-soft {
    padding: 4px 10px;
    border-radius: var(--border-radius);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-soft-success {
    background: #dcfce7;
    color: #166534;
}

.badge-soft-info {
    background: #e0f2fe;
    color: #075985;
}

.badge-soft-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-soft-danger {
    background: #fee2e2;
    color: #991b1b;
}

/* Action Icons */
.action-icon-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
    background: white;
    color: var(--text-muted);
    transition: var(--transition);
    text-decoration: none;
    font-size: 14px;
}

.action-icon-btn:hover {
    background: var(--bg-main);
    color: var(--primary);
    border-color: var(--primary);
}

.action-icon-btn.delete:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* Card View Grid */
.prescription-cards-grid {
    display: none;
    /* Controlled by JS/Toggle */
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.prescription-card {
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid var(--border);
    padding: 24px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

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

.prescription-card .card-header-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.prescription-card .patient-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.prescription-card .card-meta {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-main);
    border-radius: var(--border-radius);
}

/* Dashboard Quick Actions (Shared) */
.quick-ops-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quick-ops-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.quick-ops-item:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    transform: translateX(4px);
}

.quick-ops-item i:not(.chevron) {
    color: var(--primary);
    font-size: 18px;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

.quick-ops-item .chevron {
    color: var(--text-muted);
    font-size: 12px;
}

.prescription-card .meta-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
}

.prescription-card .meta-item i {
    width: 16px;
    color: var(--primary);
}

.prescription-card .card-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Toggle Logic */
.view-mode-table .table-container {
    display: block;
}

.view-mode-table .prescription-cards-grid {
    display: none;
}

.view-mode-card .table-container {
    display: none;
}

.view-mode-card .prescription-cards-grid {
    display: grid;
}

/* Empty State */
.empty-state-container {
    padding: 80px 40px;
    text-align: center;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 24px;
}

/* Large Scale Modals (95% Width) */
.modal-lg-heavy {
    max-width: 95% !important;
    width: 95% !important;
    margin: 20px auto;
}

/* POS Specific Enhancements */
.pos-cart-panel {
    background: white;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.03);
    border-radius: var(--border-radius);
    z-index: 10;
}

.pos-modal-view {
    margin: -15px;
    /* Offset modal padding for bleed effect if needed */
}

@media (max-width: 1024px) {
    .pos-container>div {
        grid-template-columns: 1fr !important;
        height: auto !important;
    }

    .pos-cart-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60vh;
        border-radius: var(--border-radius);
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
    }
}




/* Notification System Styles */
.notification-dropdown {
    position: absolute;
    top: 52px;
    right: 0;
    width: 380px;
    background: white;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    z-index: 10000;
    display: none;
    border-radius: 0 !important;
}

.notification-dropdown.active {
    display: block;
    animation: dropdownSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes dropdownSlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notification-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fcfdfe;
}

.notification-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.notif-mark-read {
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.notification-list {
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
    text-decoration: none;
    display: flex;
    gap: 14px;
    cursor: pointer;
}

.notification-item:hover {
    background: var(--bg-main);
}

.notification-item.unread {
    background: rgba(5, 150, 105, 0.03);
    border-left: 3px solid var(--primary);
}

.notif-icon {
    width: 40px;
    height: 40px;
    border-radius: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft);
    color: var(--primary);
    flex-shrink: 0;
    font-size: 16px;
}

.notif-content {
    flex: 1;
}

.notif-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
    display: block;
}

.notif-msg {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
    display: block;
}

.notif-time {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 6px;
    display: block;
}

.notification-footer {
    padding: 14px;
    text-align: center;
    background: #fcfdfe;
    border-top: 1px solid var(--border);
}

.notification-footer a {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    font-weight: 800;
    border: 2px solid white;
    min-width: 18px;
    height: 18px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 0 !important;
}

/* Real-time Toast Alerts */
.hms-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    background: white;
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow-xl);
    padding: 16px 20px;
    z-index: 10001;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    animation: toastSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-width: 320px;
    max-width: 400px;
    border-radius: 0 !important;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.hms-toast .notif-icon {
    background: var(--primary-soft);
    color: var(--primary);
}

/* Global Print Utilities */
@media print {
    @page {
        size: auto;
        margin: 0mm;
    }
    
    html, body {
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        overflow: visible !important;
    }

    .app-sidebar, 
    .app-header, 
    .no-print, 
    .breadcrumb, 
    .page-title-box, 
    .sidebar-footer,
    .btn { 
        display: none !important; 
    }

    .main-wrapper, .content-area, .app-container {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        position: static !important;
        height: auto !important;
        min-height: 0 !important;
    }

    /* Reset background for print */
    [style*='background: #f0f2f5'], 
    [style*='background-color: #f0f2f5'],
    .paper-mode-wrapper {
        background: white !important;
        padding: 0 !important;
        min-height: 0 !important;
    }

    .prescription-paper, .invoice-container {
        page-break-after: avoid;
        page-break-before: avoid;
        break-inside: avoid;
    }
}

/* Screen styles for Paper Mode */
body.paper-mode .app-sidebar,
body.paper-mode .app-header,
body.paper-mode #loading-overlay,
body.paper-mode #toast-container {
    display: none !important;
}

body.paper-mode .main-wrapper {
    margin-left: 0 !important;
}

body.paper-mode .content-area {
    padding: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
}

body.paper-mode .app-container {
    display: block !important;
}

/* Mobile UI Defaults (Hidden on Desktop) */
.mobile-header, .mobile-nav, .drawer-overlay, .d-only-mobile { 
    display: none !important; 
}

/* --- MOBILE APP UI TRANSFORMATION (MAX-WIDTH 768px ONLY) --- */
@media (max-width: 768px) {
    .d-only-mobile { display: block !important; }
    
    :root {
        --header-height: 56px;
        --border-radius: 12px !important;
        --shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    }

    body {
        background-color: #f8fafc;
        padding-top: var(--header-height);
        padding-bottom: 70px;
        overflow-x: hidden;
    }

    /* Fixed Modern Mobile Header */
    .mobile-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: var(--header-height);
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        color: var(--text-main);
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 0 16px;
        z-index: 10000;
        border-bottom: 1px solid var(--border);
    }

    .mobile-header .header-left,
    .mobile-header .header-right {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .mobile-header h1 {
        font-size: 16px;
        font-weight: 800;
        margin: 0;
        color: var(--text-main);
        letter-spacing: -0.02em;
    }

    .mobile-header .icon-btn {
        color: var(--text-main) !important;
        background: transparent !important;
        border: none !important;
        font-size: 18px;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
    }

    .mobile-header .icon-btn:active {
        background: var(--bg-main) !important;
    }

    /* Sidebars and Drawers */
    .app-sidebar {
        left: -280px;
        transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    }
    .app-sidebar.active {
        transform: translateX(280px);
    }

    /* Dashboard Redesign Elements */
    .card-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        margin-bottom: 24px !important;
    }

    .stat-card {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        padding: 20px 12px !important;
        gap: 12px !important;
        background: white !important;
        border: 1px solid var(--border) !important;
    }

    .stat-icon {
        width: 48px !important;
        height: 48px !important;
        font-size: 20px !important;
        border-radius: 12px !important;
        margin: 0 auto !important;
    }

    .stat-value {
        font-size: 22px !important;
        font-weight: 800 !important;
    }

    .stat-label {
        font-size: 11px !important;
        font-weight: 600 !important;
        text-transform: uppercase;
        letter-spacing: 0.02em;
        opacity: 0.8;
    }

    /* Action Buttons Grid */
    .dashboard-action-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        margin-top: 20px !important;
    }

    .dashboard-action-grid .btn {
        padding: 14px 10px !important;
        font-size: 13px !important;
        font-weight: 700 !important;
        border-radius: 12px !important;
        height: auto !important;
        flex-direction: column;
        gap: 6px;
    }

    .dashboard-action-grid .btn i {
        font-size: 16px;
    }

    /* Quick Actions List to Cards */
    .quick-ops-list {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .quick-ops-item {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        padding: 20px 12px !important;
        gap: 8px !important;
        background: white !important;
        height: 110px !important;
    }

    .quick-ops-item i:not(.chevron) {
        margin-right: 0 !important;
        font-size: 24px !important;
    }

    .quick-ops-item span {
        font-size: 12px !important;
        line-height: 1.2;
    }

    .quick-ops-item .chevron {
        display: none !important;
    }

    /* Touch Feedback */
    .btn:active, .quick-ops-item:active, .app-card:active {
        transform: scale(0.96);
        background: #f1f5f9 !important;
    }

    /* Bottom Navigation Refinement */
    .mobile-nav {
        height: 65px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
        padding-bottom: env(safe-area-inset-bottom);
        z-index: 10000;
        display: flex !important;
    }

    .mobile-nav-item {
        color: #94a3b8;
        font-weight: 700;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-nav-item i {
        font-size: 20px;
        transition: transform 0.2s ease;
    }

    .mobile-nav-item.active {
        color: var(--primary);
    }
    
    .mobile-nav-item.active i {
        transform: translateY(-2px);
    }

    /* Global Border Radius Correction for Mobile */
    [style*="border-radius: 0px"], [style*="border-radius:0px"], 
    .app-card, .btn, .form-control, .stat-icon, .notif-icon, .badge {
        border-radius: var(--border-radius) !important;
    }

    /* Mobile Table as Cards */
    .responsive-table tr {
        border-radius: 12px !important;
        padding: 20px !important;
        margin-bottom: 16px !important;
        border: 1px solid var(--border) !important;
        box-shadow: var(--shadow) !important;
    }

    .responsive-table td {
        padding: 12px 0 !important;
        border-bottom: 1px dashed var(--border) !important;
    }

    .responsive-table td:last-child {
        border-bottom: none !important;
    }
}