:root {
    --sidebar-width: 260px;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;
    --topbar-height: 64px;
    --topbar-bg: #ffffff;
    --body-bg: #f1f5f9;
    --card-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
}

* {
    font-family: 'Tajawal', sans-serif;
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--body-bg);
    color: var(--text);
}

/* Login */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 50%, #1e40af 100%);
    padding: 1rem;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.login-brand i {
    font-size: 3rem;
    color: var(--primary);
}

.login-brand h2 {
    font-weight: 800;
    margin: 0.5rem 0 0;
    color: var(--text);
}

.login-brand p {
    color: var(--text-muted);
    margin: 0;
}

/* App shell */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    transition: transform 0.25s ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
}

.sidebar-brand {
    padding: 1.1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 72px;
}

.sidebar-logo {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
}

.sidebar-logo i {
    font-size: 1.35rem;
    color: #fff;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
}

.sidebar-subtitle {
    font-size: 0.72rem;
    color: #94a3b8;
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem;
    overflow-y: auto;
}

.sidebar-nav-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    padding: 0.5rem 0.75rem 0.35rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.85rem;
    color: #94a3b8;
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 0.15rem;
    transition: background 0.15s, color 0.15s;
    font-weight: 500;
    font-size: 0.925rem;
}

.sidebar-nav .nav-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    transition: background 0.15s;
}

.sidebar-nav .nav-icon i {
    font-size: 1.1rem;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav .nav-link:hover .nav-icon {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-nav .nav-link.active {
    background: rgba(37, 99, 235, 0.2);
    color: #fff;
}

.sidebar-nav .nav-link.active .nav-icon {
    background: var(--primary);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.5);
}

.sidebar-footer {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: #94a3b8;
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-footer i {
    font-size: 1rem;
    opacity: 0.7;
}

.app-main {
    margin-right: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* Topbar */
.app-topbar {
    background: var(--topbar-bg);
    color: var(--text);
    min-height: var(--topbar-height);
    padding: 0 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-start {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
}

.topbar-breadcrumb {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.2;
}

.topbar-title h1 {
    font-size: 1.125rem;
    font-weight: 800;
    margin: 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: var(--primary-soft);
    border-radius: 999px;
    max-width: 200px;
}

.user-avatar {
    font-size: 1.5rem;
    color: var(--primary);
    line-height: 1;
}

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

.btn-topbar-logout {
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: #fff;
    border-radius: 8px;
    padding: 0.35rem 0.65rem;
}

.btn-topbar-logout:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
}

/* Content */
.app-content {
    padding: 1.25rem;
    flex: 1;
    width: 100%;
    max-width: 1400px;
}

/* Split layout (products, quotes) */
.split-layout {
    display: grid;
    grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.split-layout .split-panel {
    min-height: 420px;
    display: flex;
    flex-direction: column;
}

.split-layout .split-panel .list-scroll {
    max-height: min(65vh, 560px);
    overflow-y: auto;
}

.split-layout .split-panel .panel-card {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.split-layout .split-panel .panel-card .card-body,
.split-layout .split-panel .panel-card .list-group {
    flex: 1;
}

/* Cards */
.panel-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    background: #fff;
}

.panel-card .card-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 700;
}

.panel-card .card-header h5,
.panel-card .card-header h6 {
    margin: 0;
    font-weight: 700;
}

.table-card {
    background: #fff;
}

.table-card .table-responsive {
    border-radius: 0 0 14px 14px;
}

/* Stats */
.stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border);
    border-right: 4px solid var(--primary);
    height: 100%;
}

.stat-card.stat-success { border-right-color: #22c55e; }
.stat-card.stat-warning { border-right-color: #f59e0b; }
.stat-card.stat-info { border-right-color: #06b6d4; }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    background: var(--primary-soft);
    color: var(--primary);
    flex-shrink: 0;
}

.stat-success .stat-icon { background: #dcfce7; color: #16a34a; }
.stat-warning .stat-icon { background: #fef3c7; color: #d97706; }
.stat-info .stat-icon { background: #cffafe; color: #0891b2; }

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    display: block;
    line-height: 1.2;
    color: var(--text);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--primary-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--primary);
}

.empty-state h6 {
    color: var(--text);
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.empty-state p {
    margin: 0;
    font-size: 0.9rem;
    max-width: 280px;
    margin-inline: auto;
}

/* List items */
.list-group-item {
    border-color: var(--border);
    padding: 0.85rem 1.25rem;
}

.list-group-item.active {
    background: var(--primary);
    border-color: var(--primary);
}

.list-group-item-action:hover:not(.active) {
    background: #f8fafc;
}

/* List rows with actions (products) */
.list-item-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem !important;
    border: none !important;
    border-bottom: 1px solid var(--border) !important;
    background: #fff;
}

.list-item-row:last-child {
    border-bottom: none !important;
}

.list-item-row:hover {
    background: #f8fafc !important;
}

.list-item-row.active {
    background: var(--primary-soft) !important;
    box-shadow: inset 3px 0 0 var(--primary);
}

.list-item-row.active .list-item-title {
    color: var(--primary-dark);
    font-weight: 700;
}

.list-item-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text);
    padding: 0.35rem 0.25rem;
}

.list-item-main:hover {
    color: var(--primary);
}

.list-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.list-item-form {
    margin: 0;
    display: inline-flex;
}

.btn-action {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    line-height: 1;
    transition: all 0.15s;
}

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

.btn-action-danger:hover {
    border-color: #fca5a5;
    color: #dc2626;
    background: #fef2f2;
}

.list-item-row.active .btn-action {
    background: #fff;
}

.table-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
}

/* Quote list items */
.quote-list-item {
    display: block;
    padding: 0.85rem 1rem !important;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--border) !important;
}

.quote-list-item:hover {
    background: #f8fafc !important;
    color: inherit;
}

.quote-list-item.active {
    background: var(--primary-soft) !important;
    box-shadow: inset 3px 0 0 var(--primary);
}

.quote-list-item.active strong {
    color: var(--primary-dark);
}

.quote-list-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.quote-list-item small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Toolbar */
.page-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.filter-pills .btn {
    border-radius: 999px;
    font-size: 0.85rem;
    padding: 0.35rem 0.85rem;
}

/* Tables */
.table th {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-muted);
    background: #f8fafc;
    white-space: nowrap;
    padding: 0.75rem 1rem;
}

.table td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
}

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

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

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

.form-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}

.customer-quote-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
}

.customer-quote-title {
    font-weight: 700;
    color: #334155;
    margin-bottom: 0.75rem;
}

.customer-quote-card .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

/* Sidebar overlay mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1035;
}

body.sidebar-open .sidebar-backdrop {
    display: block;
}

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

@media (max-width: 1199px) {
    .split-layout {
        grid-template-columns: 1fr;
    }

    .split-layout .split-panel {
        min-height: auto;
    }

    .split-layout .split-panel .list-scroll {
        max-height: 280px;
    }
}

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

    .app-main {
        margin-right: 0;
    }

    .user-chip {
        max-width: 120px;
    }
}

.settings-logo-preview {
    max-width: 100%;
    max-height: 120px;
    object-fit: contain;
}

.settings-logo-placeholder {
    height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border-radius: 12px;
    color: #94a3b8;
    gap: 0.5rem;
}

.settings-logo-placeholder i {
    font-size: 2rem;
}

.quote-share-box {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.quote-share-box input {
    font-size: 0.8rem;
    direction: ltr;
    text-align: left;
}

@media (max-width: 575px) {
    .app-content {
        padding: 1rem;
    }

    .topbar-title h1 {
        font-size: 1rem;
    }

    .table-responsive {
        font-size: 0.875rem;
    }
}
