/* assets/css/main.css */

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

:root {
    --primary-color: #5b21b6; /* Deep Purple */
    --primary-hover: #4c1d95;
    --primary-light: #f3e8ff; /* Very light purple for active state backgrounds */
    --bg-light: #f8fafc; /* Very light gray/white background */
    --surface: #ffffff; /* White card backgrounds */
    --surface-border: #e2e8f0; /* Light gray border */
    --text-main: #0f172a; /* Dark text */
    --text-muted: #64748b; /* Muted text */
    --success-color: #10b981;
    --error-color: #ef4444;
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-light);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Universal Layout Classes */
.app-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Better handling of mobile URL bars */
    overflow: hidden;
}

/* Universal Module Container & Header */
.page-container {
    padding: 2.5rem;
    width: 100%;
    box-sizing: border-box;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-shrink: 0;
}

.page-title-group {
    display: flex;
    flex-direction: column;
}

.page-title-group h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.page-title-group p {
    margin: 0.25rem 0 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .page-container {
        padding: 1.5rem 1rem;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Enable native momentum scrolling on iOS */
    background-color: var(--bg-light);
}

/* Global mobile touch responsiveness */
button, 
a, 
input, 
select, 
textarea,
.nav-item,
.card {
    touch-action: manipulation; /* Removes 300ms tap delay on mobile devices */
}

.top-header {
    min-height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 2rem;
    background-color: var(--surface);
    border-bottom: 1px solid var(--surface-border);
    flex-shrink: 0;
}

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

.header-logo {
    height: 32px;
    object-fit: contain;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 0;
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-icon {
    width: 42px;
    height: 42px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-light);
    border-radius: 10px;
    border: 1px solid var(--surface-border);
}

.header-icon:hover {
    color: var(--text-main);
    background-color: var(--surface-border);
}

.header-icon svg {
    width: 22px;
    height: 22px;
}

.user-avatar {
    width: 42px;
    height: 42px;
    background-color: #6366f1; /* Indigo */
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.logout-btn {
    color: var(--error-color);
}
.logout-btn:hover {
    color: #b91c1c;
}

/* Universal Sidebar Styles */
.universal-sidebar {
    width: 212px;
    height: 100vh;
    background-color: #000000; /* Black Theme */
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    z-index: 10;
    flex-shrink: 0;
    position: relative; /* For absolute toggle button */
    border-top-right-radius: 15px;
    border-bottom-right-radius: 15px;
}

.universal-sidebar.collapsed {
    width: 72px;
}

.sidebar-header {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    border-bottom: 1px solid #222;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    font-weight: 400;
    font-size: 1.1rem;
    overflow: hidden;
    white-space: nowrap;
}

.brand-favicon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.brand-icon {
    width: 24px;
    height: 24px;
    color: var(--success-color);
}

.sidebar-collapse-btn {
    position: absolute;
    right: -12px;
    top: 20px;
    background: #ffffff;
    border: 1px solid var(--surface-border);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    z-index: 20;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sidebar-collapse-btn:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
}

.universal-sidebar.collapsed .brand-text {
    display: none;
}

.sidebar-content {
    padding: 1rem 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.nav-list {
    list-style: none;
    padding: 0 0.5rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.nav-item {
    border-radius: 8px;
    overflow: hidden;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-weight: 400;
    font-size: 0.95rem;
    transition: all 0.2s;
    border-radius: 8px;
}

.nav-link:hover {
    background-color: #1f2937;
    color: #ffffff;
}

.nav-item.active .nav-link {
    background-color: #374151;
    color: #ffffff;
}

.nav-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}

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

.sidebar-search {
    margin: auto 1rem 1rem 1rem;
    position: relative;
    display: flex;
    align-items: center;
}

.sidebar-search svg {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.sidebar-search input {
    width: 100%;
    padding: 0.5rem 0.5rem 0.5rem 2rem;
    background-color: var(--bg-light);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.85rem;
}

.sidebar-search input:focus {
    outline: none;
    border-color: var(--primary-color);
}

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

/* Universal Toast Notification */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast-message {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    color: var(--text-main);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: translateY(-20px);
    animation: toastSlideIn 0.3s ease forwards;
}

.toast-message.success {
    border-left: 4px solid var(--success-color);
}

.toast-message.error {
    border-left: 4px solid var(--error-color);
}

.toast-message.fade-out {
    animation: toastSlideOut 0.3s ease forwards;
}

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

@keyframes toastSlideOut {
    to { opacity: 0; transform: translateY(-20px); }
}

/* Universal Full Screen Pre-loader - Stunning Glassmorphic Light Design */
#preloader {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(248, 250, 252, 0.88); /* Crisp slate light-gray glass */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.25, 1, 0.5, 1), visibility 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

#preloader.active {
    opacity: 1;
    visibility: visible;
}

/* Futuristic Concentration Loader */
.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(99, 102, 241, 0.08);
    border-top: 3px solid #6366f1;
    border-radius: 50%;
    animation: spinLoader 1s cubic-bezier(0.55, 0.055, 0.675, 0.19) infinite;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.12);
    position: relative;
}

.spinner::before {
    content: '';
    position: absolute;
    top: 4px; left: 4px; right: 4px; bottom: 4px;
    border: 2px solid rgba(236, 72, 153, 0.06);
    border-bottom: 2px solid #ec4899;
    border-radius: 50%;
    animation: spinLoaderReverse 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.preloader-text {
    margin-top: 1.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-main, #0f172a);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    animation: textPulse 2s ease-in-out infinite;
    font-family: 'Inter', sans-serif;
    opacity: 0.85;
}

@keyframes spinLoader {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes spinLoaderReverse {
    0% { transform: rotate(360deg); }
    100% { transform: rotate(0deg); }
}

@keyframes textPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.module-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease-in-out;
    opacity: 1;
}

.module-container.fade-out {
    opacity: 0;
}

/* Hide elements not meant for desktop */
.mobile-close-sidebar-btn {
    display: none;
}
.mobile-bottom-tabs {
    display: none;
}

/* Mobile Media Queries */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: none !important; /* Replaced by bottom tabs */
    }
    
    .header-actions .user-avatar,
    .header-actions .logout-btn {
        display: none !important; /* Hidden on mobile */
    }

    .universal-sidebar {
        position: fixed;
        top: 0;
        left: -212px;
        height: 100vh;
        z-index: 100;
        transition: left 0.3s ease;
        /* Ensure width is expanded on mobile */
        width: 212px !important;
    }

    .universal-sidebar.mobile-open {
        left: 0;
    }

    /* Force text visibility when mobile sidebar is open, overriding .collapsed */
    .universal-sidebar.mobile-open .nav-text {
        display: inline;
    }

    .sidebar-collapse-btn {
        display: none; /* Hide desktop toggle button on mobile */
    }

    .mobile-close-sidebar-btn {
        display: block;
        background: none;
        border: none;
        color: var(--text-muted);
        cursor: pointer;
        padding: 0;
    }
    .mobile-close-sidebar-btn:hover {
        color: var(--text-main);
    }
    .mobile-close-sidebar-btn svg {
        width: 24px;
        height: 24px;
    }

    /* Overlay */
    .sidebar-overlay {
        position: fixed;
        top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 90;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
    }

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

    .top-header {
        padding: 0 1rem;
    }

    /* Mobile Bottom Tabs */
    .mobile-bottom-tabs {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 65px;
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(10px);
        border-top: 1px solid var(--surface-border);
        z-index: 80;
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
    }
    
    .bottom-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        color: var(--text-muted);
        text-decoration: none;
        flex: 1;
        background: none;
        border: none;
        cursor: pointer;
        font-family: inherit;
        padding: 0;
        transition: all 0.2s;
    }
    
    .bottom-tab.active, .bottom-tab:hover {
        color: var(--primary-color);
    }
    
    .bottom-tab svg {
        width: 24px;
        height: 24px;
        transition: transform 0.2s;
    }
    
    .bottom-tab:hover svg {
        transform: translateY(-2px);
    }
    
    .bottom-tab span {
        font-size: 0.75rem;
        font-weight: 500;
    }

    .module-container {
        padding-bottom: 80px; /* Space for bottom tabs */
    }
}

/* Custom Confirm Modal */
.custom-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: none; /* Changed to flex via JS */
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.custom-confirm-overlay.active {
    opacity: 1;
}

.custom-confirm-box {
    background: var(--surface);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 90%;
    max-width: 400px;
    transform: scale(0.95) translateY(10px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--surface-border);
}

.custom-confirm-overlay.active .custom-confirm-box {
    transform: scale(1) translateY(0);
}

.custom-confirm-box h3 {
    margin: 0 0 0.75rem 0;
    color: var(--text-main);
    font-size: 1.25rem;
}

.custom-confirm-box p {
    color: var(--text-muted);
    margin: 0 0 1.5rem 0;
    line-height: 1.5;
    font-size: 0.95rem;
}

.custom-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Global Button Styles */
.btn-danger {
    background: var(--error-color);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.2);
}

.btn-secondary {
    background-color: var(--surface);
    color: var(--text-main);
    border: 1px solid var(--surface-border);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

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


/* --- Common Standards Imported from users.css --- */
.header-actions-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Search Bar */
.search-container {
    position: relative;
    width: 100%;
    max-width: 300px;
}

.search-container .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.search-container input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    background-color: var(--surface);
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    box-sizing: border-box;
}

.search-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(91, 33, 182, 0.2), 0 2px 4px -1px rgba(91, 33, 182, 0.1);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(91, 33, 182, 0.3), 0 4px 6px -2px rgba(91, 33, 182, 0.15);
}

.btn-primary svg, .btn-secondary svg, .btn-outline svg {
    width: 16px;
    height: 16px;
}

.btn-secondary {
    background-color: var(--surface);
    color: var(--text-main);
    border: 1px solid var(--surface-border);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

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

.btn-outline {
    background: transparent;
    border: 1px dashed var(--text-muted);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

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

/* Stunning Table */
.table-container {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    margin-top: 1.5rem;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.8);
    position: relative;
    box-sizing: border-box;
    width: 100%;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--surface-border);
    background: linear-gradient(to right, #f8fafc, #ffffff);
    flex-wrap: wrap;
    gap: 1rem;
}

.table-header-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-main);
}

.stunning-table table {
    width: 100%;
    border-collapse: collapse;
}

.stunning-table th {
    text-align: left;
    padding: 0.75rem 1.2rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background-color: #f1f5f9;
}

.stunning-table td {
    padding: 0.85rem 1.2rem;
    border-bottom: 1px solid var(--surface-border);
    color: var(--text-main);
    font-size: 0.85rem;
    word-break: break-word;
    overflow-wrap: break-word;
}

.stunning-table tbody tr {
    transition: all 0.2s ease;
    cursor: pointer;
}

.stunning-table tbody tr:hover {
    background-color: var(--primary-light);
    transform: scale(1.002);
    box-shadow: inset 2px 0 0 var(--primary-color);
}

.user-name-cell {
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Status Badges */
.status-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

.status-active {
    background-color: #d1fae5;
    color: #065f46;
}

.status-inactive {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Right Slider Overlay */
.slider-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Right Slider */
.right-slider {
    position: fixed;
    top: 0;
    right: -70%;
    width: 60%;
    height: 100vh;
    background-color: #f8fafc;
    z-index: 1001;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
    transition: right 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.right-slider.active {
    right: 0;
}

@media (max-width: 1024px) {
    .right-slider {
        width: 70%;
        right: -80%;
    }
}

@media (max-width: 768px) {
    .right-slider {
        width: 100%;
        right: -110%;
    }
    
    /* Toolbar adjustments */
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem 0;
        border-bottom: none;
        background: transparent;
    }
    .table-header-title {
        display: none;
    }
    .header-actions-right {
        flex-direction: column;
        width: 100%;
        gap: 1rem;
    }
    .search-container {
        width: 100%;
    }

    /* Floating Action Button (FAB) */
    #add-user-btn {
        position: fixed;
        bottom: 2rem;
        right: 1.5rem;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        padding: 0;
        justify-content: center;
        z-index: 900;
        box-shadow: 0 4px 15px rgba(91, 33, 182, 0.4);
    }
    #add-user-btn .btn-text {
        display: none;
    }
    #add-user-btn svg {
        width: 24px;
        height: 24px;
        margin: 0;
    }

    /* Card Layout for Table */
    .stunning-table table {
        display: block;
    }
    .stunning-table thead {
        display: none;
    }
    .stunning-table tbody {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        padding-bottom: 5rem; /* space for FAB */
    }
    .stunning-table tr {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto auto;
        gap: 0.5rem;
        padding: 1.2rem;
        background: var(--surface);
        border: 1px solid var(--surface-border);
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    }
    .stunning-table td {
        padding: 0;
        border: none;
        font-size: 0.9rem;
    }
    .stunning-table td:nth-child(1) {
        grid-column: 1 / 2;
        grid-row: 1 / 2;
    }
    .stunning-table td:nth-child(4) {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
        justify-self: end;
    }
    .stunning-table td:nth-child(2) {
        grid-column: 1 / 3;
        grid-row: 2 / 3;
        color: var(--text-muted);
        font-size: 0.85rem;
        margin-top: 0.25rem;
    }
    .stunning-table td:nth-child(3) {
        grid-column: 1 / 3;
        grid-row: 3 / 4;
        color: var(--text-muted);
        font-size: 0.85rem;
    }
    .stunning-table tbody tr:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--surface-border);
}

.slider-header h2 {
    margin: 0;
    font-size: 1.4rem;
    background: linear-gradient(135deg, var(--text-main) 0%, #334155 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.close-slider-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
}

.close-slider-btn:hover {
    background: #f1f5f9;
    color: var(--text-main);
    transform: rotate(90deg);
}

.close-slider-btn svg {
    width: 24px;
    height: 24px;
}

.slider-tabs {
    display: flex;
    padding: 0 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--surface-border);
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.slider-tabs::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Edge */
}

.tab-btn {
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.3s;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .slider-tabs {
        padding: 0 1rem;
    }
    .tab-btn {
        padding: 0.8rem 1rem;
        font-size: 0.85rem;
    }
}

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

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    position: relative;
    background: linear-gradient(to top, rgba(99, 102, 241, 0.08) 0%, transparent 100%);
    border-radius: 8px 8px 0 0;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary-color);
    box-shadow: 0 -2px 10px var(--primary-color);
    border-radius: 3px 3px 0 0;
}

.slider-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    /* Subtle inner shadow for depth */
    box-shadow: inset 0 10px 20px -10px rgba(0,0,0,0.05);
}

/* 3D Shiny Card Style */
.shiny-card-container {
    background: var(--surface);
    border-radius: 16px;
    padding: 2rem;
    position: relative;
    box-shadow: 
        0 20px 40px -10px rgba(0,0,0,0.05), /* Large soft shadow */
        0 1px 3px rgba(0,0,0,0.05),
        inset 0 1px 0 rgba(255,255,255,1); /* Top shine highlight */
    border: 1px solid rgba(255, 255, 255, 0.4);
    background-image: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 100%);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease;
}

.shiny-card-container:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 25px 50px -12px rgba(0,0,0,0.1),
        0 1px 3px rgba(0,0,0,0.05),
        inset 0 1px 0 rgba(255,255,255,1);
}

.tab-pane {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.tab-pane.active {
    display: block;
}

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

/* Forms within slider */
.form-row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

.form-row.align-end {
    align-items: flex-end;
}

.form-group {
    flex: 1;
    margin-bottom: 1.5rem;
}

.form-group.auto-width {
    flex: 0 0 auto;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="datetime-local"],
.form-group input[type="time"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    background-color: #f8fafc;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
    box-sizing: border-box;
    color: var(--text-main);
}

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2em;
    padding-right: 2.5rem;
}

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

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Mild 3D Card Form Sections */
.form-tab-pane {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(226, 232, 240, 0.8);
    background-image: linear-gradient(to bottom right, #ffffff, #f8fafc);
    margin-bottom: 20px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider.round {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
    background-color: #ccc;
    border-radius: 24px;
    transition: .4s;
    margin-right: 10px;
}

.slider.round:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider.round {
    background-color: var(--success-color);
}

input:checked + .slider.round:before {
    transform: translateX(22px);
}

.toggle-label {
    font-weight: 500;
    font-size: 0.95rem;
}

/* Role Chips */
.roles-group {
    background: rgba(248, 250, 252, 0.5);
    padding: 1rem;
    border-radius: 10px;
    border: 1px solid var(--surface-border);
}

.roles-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.role-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.role-chip:hover {
    border-color: var(--primary-color);
}

.role-chip input {
    accent-color: var(--primary-color);
    cursor: pointer;
}

.role-chip input:disabled {
    opacity: 0.5;
}

.role-chip:has(input:checked) {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-hover);
}

/* Attachments */
.attachment-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.attachment-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    padding: 0;
    margin: 1rem 0 0 0;
    list-style: none;
}

.attachment-item-enhanced {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
    position: relative;
    transition: all 0.2s ease;
}

.attachment-item-enhanced:hover {
    border-color: var(--primary-light);
    box-shadow: 0 4px 10px rgba(91, 33, 182, 0.08);
    transform: translateY(-1px);
}

.attachment-thumb {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--surface-border);
}

.attachment-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.doc-thumb {
    color: var(--text-muted);
}

.doc-thumb svg {
    width: 22px;
    height: 22px;
}

.attachment-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.attachment-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-size {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.attachment-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.attachment-item-enhanced:hover .attachment-actions {
    opacity: 1;
}

.action-btn-enhanced {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    text-decoration: none;
}

.action-btn-enhanced:hover {
    background: var(--bg-light);
}

.action-btn-enhanced svg {
    width: 18px;
    height: 18px;
}

.view-btn:hover {
    color: var(--primary-color);
    background: var(--primary-light);
}

.download-btn:hover {
    color: #0284c7; /* blue */
    background: #e0f2fe;
}

.remove-btn-enhanced:hover {
    color: var(--error-color);
    background: #fee2e2;
}

/* Other Info Tab specific */
.other-info-header {
    margin-bottom: 2rem;
}
.other-info-header h3 {
    margin: 0 0 0.5rem 0;
}
.other-info-header p {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.9rem;
}

.dynamic-fields {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.dynamic-field-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--surface-border);
    animation: fadeIn 0.3s ease;
}

.dynamic-field-row .field-key {
    font-weight: 600;
    width: 30%;
    color: var(--text-muted);
}

.dynamic-field-row .field-val {
    flex: 1;
    font-weight: 500;
}

.remove-field-btn {
    background: none;
    border: none;
    color: var(--error-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
}
.remove-field-btn:hover {
    background: #fee2e2;
}

.add-field-container {
    background: rgba(91, 33, 182, 0.03);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px dashed var(--primary-color);
    margin-bottom: 1rem;
}

.mt-4 { margin-top: 2rem; }

/* Stunning Upload Progress Overlay */
.upload-progress-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(248, 250, 252, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    border-radius: 16px;
}

.upload-progress-overlay.active {
    opacity: 1;
    visibility: visible;
}

.progress-card {
    background: white;
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.05);
    text-align: center;
    max-width: 400px;
    width: 90%;
    border: 1px solid rgba(91, 33, 182, 0.1);
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.progress-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-light) 0%, #e0e7ff 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem auto;
    color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(91, 33, 182, 0.15);
}

.progress-icon svg {
    width: 32px;
    height: 32px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0px); }
}

.progress-card h3 {
    margin: 0 0 0.5rem 0;
    color: var(--text-main);
    font-size: 1.25rem;
}

.progress-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 2rem 0;
}

.progress-bar-container {
    height: 12px;
    background: #f1f5f9;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 1rem;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    border-radius: 20px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    background-size: 200% 100%;
    animation: gradientMove 2s linear infinite;
}

@keyframes gradientMove {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.progress-text {
    font-weight: 700;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #d946ef 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-variant-numeric: tabular-nums;
}

/* Footer Styles */
.global-footer {
    width: 100%;
    background: var(--surface);
    border-top: 1px solid var(--surface-border);
    padding: 1.5rem 2rem;
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.footer-brand {
    font-weight: 500;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

.footer-separator {
    color: var(--surface-border);
}

/* Policy Sliders */
.policy-slider-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.policy-slider {
    position: fixed;
    top: 0;
    right: -50%;
    width: 50%;
    height: 100%;
    background: var(--bg-light);
    z-index: 1050;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.policy-slider.open {
    right: 0;
}

.policy-slider-overlay.active {
    opacity: 1;
    visibility: visible;
}

.policy-slider-header {
    padding: 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.policy-slider-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-main);
}

.close-policy-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    transition: all 0.2s ease;
    border-radius: 50%;
}

.close-policy-btn:hover {
    background: var(--surface-border);
    color: var(--text-main);
}

.close-policy-btn svg {
    width: 24px;
    height: 24px;
}

.policy-slider-content {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
    color: var(--text-main);
}

.policy-slider-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
}

.policy-slider-content h3:first-child {
    margin-top: 0;
}

.policy-slider-content p {
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .policy-slider {
        width: 100%;
        right: -110%;
    }
    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

.policy-cards-layout {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.5rem !important;
}

.policy-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.policy-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

.policy-card h3 {
    margin-top: 0 !important;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem !important;
    color: var(--primary-color) !important;
    border-bottom: 1px solid var(--surface-border);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem !important;
}

.policy-card h3 svg {
    width: 20px;
    height: 20px;
}

.policy-card p {
    font-size: 0.85rem !important;
    color: var(--text-muted) !important;
    line-height: 1.6 !important;
    margin: 0 !important;
}

/* --- Dr. AI Assistant Styles --- */
.header-ai-btn {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(59, 130, 246, 0.15) 100%);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 24px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.15), inset 0 0 10px rgba(255, 255, 255, 0.5);
    position: relative;
    overflow: hidden;
}

.header-ai-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0) 100%);
    transform: skewX(-25deg);
    animation: aiShine 3s infinite;
}

@keyframes aiShine {
    0% { left: -100%; }
    20% { left: 200%; }
    100% { left: 200%; }
}

.header-ai-btn:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25) 0%, rgba(59, 130, 246, 0.25) 100%);
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.3), inset 0 0 15px rgba(255, 255, 255, 0.6);
    transform: translateY(-2px) scale(1.02);
}
.header-ai-btn svg { width: 22px; height: 22px; filter: drop-shadow(0 0 4px rgba(139, 92, 246, 0.6)); }
.header-ai-btn span {
    font-weight: 700;
    font-size: 1.05rem;
    background: linear-gradient(135deg, #8b5cf6, #d946ef, #3b82f6, #8b5cf6);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: aiTextGradientShift 4s ease infinite;
}

@keyframes aiTextGradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.drai-sparkle-icon {
    animation: sparkleScale 2s ease-in-out infinite alternate;
}

@keyframes sparkleScale {
    0% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 2px 4px rgba(49, 10, 107, 0.4)) brightness(1); }
    100% { transform: scale(1.05) rotate(2deg); filter: drop-shadow(0 4px 8px rgba(147, 51, 234, 0.6)) brightness(1.2); }
}

.drai-slider {
    width: 50%;
    max-width: 750px;
    min-width: 350px;
    background: transparent;
    box-shadow: none;
    border-left: none;
    padding: 15px;
    display: flex;
    flex-direction: column;
}
.drai-slider-overlay {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
}
.drai-frame-border {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 24px;
    padding: 2px; /* For the gradient border */
    background: linear-gradient(135deg, #8b5cf6, #3b82f6, #ec4899);
    box-shadow: -10px 0 30px rgba(139, 92, 246, 0.3), 0 20px 40px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.drai-inner-content {
    background: var(--surface);
    border-radius: 22px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
.drai-inner-content::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at top right, rgba(139, 92, 246, 0.05), transparent 60%);
    pointer-events: none;
}

.drai-header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(139, 92, 246, 0.1);
    z-index: 10;
}
.drai-avatar {
    width: 40px;
    height: 40px;
    background: var(--bg-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}
.drai-avatar svg { width: 24px; height: 24px; }

.drai-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}
.drai-chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.drai-message {
    display: flex;
    gap: 12px;
    max-width: 90%;
    animation: toastSlideIn 0.3s ease forwards;
}
.drai-message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.drai-message.assistant-message {
    align-self: flex-start;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    color: var(--primary-color);
}
.user-message .msg-avatar {
    background: var(--primary-color);
    color: white;
}

.msg-bubble {
    background: var(--bg-light);
    padding: 12px 16px;
    border-radius: 16px;
    border-top-left-radius: 4px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-main);
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
    word-break: break-word;
}
.user-message .msg-bubble {
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    color: white;
    border-top-left-radius: 16px;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 10px rgba(91, 33, 182, 0.2);
}

/* Markdown specific styles within msg-bubble */
.msg-bubble p { margin: 0 0 0.75rem 0; }
.msg-bubble p:last-child { margin: 0; }
.msg-bubble strong { font-weight: 600; }
.msg-bubble ul, .msg-bubble ol { margin: 0; padding-left: 1.25rem; }
.msg-bubble li { margin-bottom: 0.25rem; }
.msg-bubble code {
    background: rgba(0,0,0,0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85em;
}
.user-message .msg-bubble code { background: rgba(255,255,255,0.2); }

.drai-input-area {
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(139, 92, 246, 0.1);
}
#drai-input {
    flex: 1;
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    padding: 12px 20px;
    padding-right: 50px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    max-height: 150px;
    background: var(--bg-light);
    transition: all 0.3s;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}
#drai-input:focus {
    outline: none;
    border-color: #8b5cf6;
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}
.drai-send-btn {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #8b5cf6, #3b82f6);
}
.drai-send-btn svg {
    width: 18px;
    height: 18px;
    margin-right: -2px; /* slight visual offset for paper plane */
}

@media (max-width: 768px) {
    .drai-slider { width: 100%; min-width: 100%; padding: 0; border-radius: 0; }
    .drai-frame-border { border-radius: 0; padding: 0; border-top: 2px solid #8b5cf6; }
    .drai-inner-content { border-radius: 0; }
    .header-ai-btn span { display: none; }
}

.drai-loading-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
}
.drai-loading-dots span {
    width: 6px;
    height: 6px;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: inline-block;
    animation: draiBounce 1.4s infinite ease-in-out both;
}
.drai-loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.drai-loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes draiBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Table styling for AI responses */
.drai-ai-table-container {
    width: 100%;
    overflow-x: auto;
    margin: 10px 0;
    border-radius: 8px;
    border: 1px solid var(--surface-border);
}
.drai-ai-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.drai-ai-table th {
    background: var(--bg-light);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-main);
    border-bottom: 2px solid var(--surface-border);
}
.drai-ai-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--surface-border);
    color: var(--text-muted);
}

/* Modal Styles Global (moved from dashboard) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(2px);
}

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

.modal-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    width: 90%;
    max-width: 350px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: translateY(20px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

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

.modal-header h2, .modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.close-modal-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-modal-btn svg {
    width: 20px;
    height: 20px;
}

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

/* Global Code/Selection Pills */
.code-pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    min-height: 34px;
    padding: 4px;
    border: 1px dashed var(--surface-border);
    border-radius: 6px;
    background: #fafafa;
}

.code-pill {
    display: inline-flex;
    align-items: center;
    background: #e0e7ff; /* indigo-100 */
    color: #3730a3; /* indigo-800 */
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid #c7d2fe; /* indigo-200 */
}

.code-pill.cpt-pill {
    background: #dcfce7; /* green-100 */
    color: #166534; /* green-800 */
    border-color: #bbf7d0; /* green-200 */
}

.code-pill span.desc {
    font-weight: 400;
    margin-left: 5px;
    opacity: 0.8;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.code-pill-remove {
    margin-left: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(0,0,0,0.1);
    transition: background 0.2s;
}

.code-pill-remove:hover {
    background: rgba(0,0,0,0.2);
    color: #000;
}

.code-pill-remove svg {
    width: 12px;
    height: 12px;
}

/* ==========================================================================
   iPad Pro & Universal Tablet Responsiveness (11" & 13")
   ========================================================================== */

/* iPad Landscape (1025px - 1366px) */
@media (min-width: 1025px) and (max-width: 1366px) {
    .page-container {
        padding: 2rem;
    }
    .universal-sidebar {
        width: 212px;
    }
    /* Enhance touch targets slightly */
    .btn-primary, .btn-secondary, .btn-danger, .btn-outline {
        padding: 0.75rem 1.25rem;
        font-size: 1rem;
    }
    .nav-link {
        padding: 0.75rem 1rem;
    }
}

/* iPad Portrait & Small Tablets (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .page-container {
        padding: 1.5rem;
    }
    /* Auto-collapse sidebar to save space */
    .universal-sidebar {
        width: 72px;
    }
    .universal-sidebar .brand-text,
    .universal-sidebar .nav-text,
    .universal-sidebar .sidebar-search {
        display: none;
    }
    /* Bigger touch targets */
    .btn-primary, .btn-secondary, .btn-danger, .btn-outline {
        padding: 0.8rem 1.25rem;
        font-size: 1rem;
    }
    .nav-link {
        padding: 0.75rem 1rem;
        justify-content: center;
    }
    .nav-icon {
        margin: 0;
    }
    .header-actions {
        gap: 1rem;
    }
}

/* Enhancements for all touch devices up to iPad Pro 13" Landscape */
@media (max-width: 1366px) {
    /* Prevent hover effects from getting stuck on touch */
    .btn-primary:hover, .btn-secondary:hover, .btn-danger:hover {
        transform: none;
    }
    .policy-card:hover {
        transform: none;
    }
    /* General touch spacing */
    input[type="text"], input[type="email"], input[type="password"], select, textarea, .search-container input {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 0.75rem 1rem;
    }
    .search-container input {
        padding-left: 2.5rem;
    }
}
