@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0b132b;
    --bg-sidebar-hover: #1c2541;
    --bg-sidebar-active: #3a506b;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --text-white: #ffffff;
    
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;
    
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --accent-light: #fef3c7;
    
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    
    --border-color: #e2e8f0;
    --border-dark: #cbd5e1;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Visible Custom Modern Scrollbars */
html {
    overflow-y: scroll;
}

::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 6px;
    border: 2px solid #f1f5f9;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

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

/* Layout Framework */
.app-container {
    display: flex;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.app-sidebar {
    width: 270px;
    background: linear-gradient(180deg, #283a5c 0%, #1e2b44 50%, #162033 100%);
    color: #f1f5f9;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.18);
    transition: transform 0.25s ease;
}

.sidebar-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 100px;
    height: auto;
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    flex: 1;
    min-width: 0;
}

.sidebar-logo-img {
    max-height: 84px;
    width: auto;
    max-width: 230px;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.45));
}

.sidebar-close-btn {
    display: none;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
    margin-left: 8px;
}

.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.sidebar-close-btn svg {
    width: 18px;
    height: 18px;
    display: block;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(9, 17, 36, 0.65);
    backdrop-filter: blur(2px);
    z-index: 90;
}

.brand-badge {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    color: #ffffff;
    box-shadow: 0 0 15px rgba(2, 132, 199, 0.5);
}

.brand-info h2 {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.2px;
    color: #ffffff;
    line-height: 1.2;
}

.brand-info span {
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.app-sidebar {
    /* Allow native scroll */
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.sidebar-nav::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.nav-section-title {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #94a3b8;
    padding: 12px 12px 6px 12px;
    margin-top: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: #cbd5e1;
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 3px;
    transition: all 0.15s ease;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: #94a3b8;
    transition: color 0.15s ease;
}

.nav-item:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.09);
}

.nav-item:hover svg {
    color: #ffffff;
}

.nav-item.active {
    color: #ffffff;
    background: linear-gradient(90deg, rgba(2, 132, 199, 0.35) 0%, rgba(2, 132, 199, 0.12) 100%);
    border-left: 3px solid #0284c7;
    font-weight: 700;
    box-shadow: none;
}

.nav-item.active svg {
    color: #38bdf8;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.15);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.user-info h4 {
    font-size: 13px;
    font-weight: 700;
    color: #e2e8f0;
}

.user-info span {
    font-size: 11px;
    color: #94a3b8;
    text-transform: capitalize;
}

/* Main Content Area */
.app-main {
    flex: 1 1 auto;
    margin-left: 270px;
    width: calc(100% - 270px);
    max-width: calc(100% - 270px);
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    box-sizing: border-box;
    overflow-x: hidden;
}

.app-topbar {
    height: 64px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 40;
    width: 100%;
    box-sizing: border-box;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.mobile-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.mobile-toggle:hover, .mobile-toggle:active {
    background-color: #f1f5f9;
    color: var(--primary);
    border-color: var(--border-dark);
}

.mobile-toggle svg {
    width: 20px;
    height: 20px;
    display: block;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.page-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.3px;
    white-space: nowrap;
}

.content-body {
    padding: 24px;
    flex: 1;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Luxury Grid & Cards */
.grid-cols-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

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

.grid-cols-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

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

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

.card-header h3 {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-main);
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background-color: #f8fafc;
}

/* Stat Cards */
.stat-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 22px;
    position: relative;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stat-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.blue { background-color: var(--primary-light); color: var(--primary); }
.stat-icon.green { background-color: var(--success-light); color: var(--success); }
.stat-icon.amber { background-color: var(--accent-light); color: var(--accent); }
.stat-icon.purple { background-color: #f3e8ff; color: #9333ea; }
.stat-icon.red { background-color: var(--danger-light); color: var(--danger); }

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

.stat-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f8fafc;
}

.table-responsive::-webkit-scrollbar {
    display: block;
    height: 8px;
    width: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f8fafc;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.table {
    width: 100%;
    min-width: 660px;
    border-collapse: collapse;
    font-size: 13.5px;
    text-align: left;
}

.table th {
    background-color: #f8fafc;
    padding: 11px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

.table-compact th {
    padding: 9px 8px;
    font-size: 10.5px;
}

.table-compact td {
    padding: 9px 8px;
    font-size: 12.5px;
}

.table tbody tr {
    transition: background-color 0.12s ease;
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1;
}

.badge-success { background-color: var(--success-light); color: #065f46; }
.badge-warning { background-color: var(--warning-light); color: #92400e; }
.badge-danger { background-color: var(--danger-light); color: #991b1b; }
.badge-info { background-color: var(--primary-light); color: #075985; }
.badge-neutral { background-color: #f1f5f9; color: #475569; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.4;
}

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

.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff !important;
    box-shadow: 0 1px 3px rgba(2, 132, 199, 0.3);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 6px -1px rgba(2, 132, 199, 0.4);
}

.btn-dark {
    background-color: #0f172a;
    color: #ffffff !important;
}

.btn-dark:hover {
    background-color: #1e293b;
}

.btn-secondary {
    background-color: #ffffff;
    border-color: var(--border-color);
    color: #334155 !important;
}

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

.btn-success {
    background-color: var(--success);
    color: #ffffff !important;
}

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

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

.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: #ffffff;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-main);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

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

.form-row {
    display: flex;
    gap: 16px;
}

.form-col {
    flex: 1;
}

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background-color: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.alert-danger {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.alert-warning {
    background-color: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.alert-info {
    background-color: #f0f9ff;
    border: 1px solid #bae6fd;
    color: #0369a1;
}

/* Multi-Step Wizard */
.wizard-steps {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background-color: #ffffff;
    overflow-x: auto;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f8fafc;
}

.wizard-steps::-webkit-scrollbar {
    display: block;
    height: 6px;
}

.wizard-steps::-webkit-scrollbar-track {
    background: #f8fafc;
}

.wizard-steps::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.wizard-steps::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.wizard-step {
    padding: 14px 20px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.wizard-step.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background-color: #f8fafc;
}

.wizard-step.completed {
    color: var(--success);
}

.step-number {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-full);
    background-color: #e2e8f0;
    color: #475569;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.wizard-step.active .step-number {
    background-color: var(--primary);
    color: #ffffff;
}

.wizard-step.completed .step-number {
    background-color: var(--success);
    color: #ffffff;
}

/* Signature Pad */
.signature-wrapper {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    background-color: #ffffff;
    padding: 12px;
    text-align: center;
    position: relative;
}

.signature-canvas {
    width: 100%;
    height: 160px;
    touch-action: none;
    cursor: crosshair;
}

.signature-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

/* Mobile responsive adjustments */
@media (max-width: 1024px) {
    .app-sidebar {
        transform: translateX(-100%);
        z-index: 100;
        box-shadow: 8px 0 24px rgba(0, 0, 0, 0.45);
    }
    .app-sidebar.open {
        transform: translateX(0);
    }
    .app-main {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }
    .mobile-toggle {
        display: inline-flex;
    }
    .sidebar-close-btn {
        display: inline-flex;
    }
    .sidebar-backdrop {
        display: block;
    }
    .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .grid-cols-3, .grid-cols-2 {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .content-body {
        padding: 16px;
    }
    .stat-card {
        padding: 16px;
    }
    .stat-value {
        font-size: 24px;
    }
    .card-footer {
        flex-direction: column;
        gap: 12px;
        align-items: stretch !important;
    }
    .card-footer > div {
        width: 100%;
    }
    .card-footer > div:last-child {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    .card-footer .btn {
        width: 100%;
        justify-content: center;
    }
/* Universal Modal System */
[x-cloak] {
    display: none !important;
}

.modal-backdrop,
.app-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

.app-modal-backdrop[style*="display: none"],
.modal-backdrop[style*="display: none"] {
    display: none !important;
}

.app-modal-backdrop > .card,
.modal-backdrop > .card,
.app-modal-dialog {
    margin: auto !important;
    width: 100%;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

@media (max-width: 640px) {
    .app-topbar {
        padding: 0 12px;
        height: 56px;
    }
    .topbar-left {
        gap: 8px;
        min-width: 0;
        flex: 1;
    }
    .page-title {
        font-size: 15px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .content-body {
        padding: 12px;
    }
    .card-header {
        padding: 14px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .card-header h3 {
        font-size: 14px;
    }
    .card-body {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .grid-cols-4 {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .page-title {
        font-size: 14px;
        max-width: 150px;
    }
    .topbar-right .btn span {
        display: none;
    }
    .topbar-right .btn {
        padding: 7px 10px;
    }
    .topbar-right .btn svg {
        margin: 0 !important;
    }
    .stat-card {
        padding: 14px;
    }
}
