/* ==========================================================================
   CRM-style Contact / Customer Detail Page
   Used by resources/views/contact/show.blade.php
   ========================================================================== */

.crm-contact-profile {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.06);
    border: 1px solid #e2e8f0;
}

/* ---------- Header strip ---------- */
.crm-profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px 28px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    flex-wrap: wrap;
}

.crm-profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    border: 2px solid rgba(255,255,255,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    flex-shrink: 0;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.crm-profile-identity { flex: 1; min-width: 220px; }

.crm-profile-name {
    margin: 0 0 8px 0;
    font-size: 22px;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
}

.crm-profile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.crm-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255,255,255,0.2);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.crm-badge i { font-size: 10px; }

.crm-badge-customer { background: rgba(34, 197, 94, 0.85); }
.crm-badge-supplier { background: rgba(245, 158, 11, 0.9); }
.crm-badge-lead     { background: rgba(236, 72, 153, 0.85); }

.crm-meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.25);
}
.crm-meta-chip i { font-size: 9px; }
.crm-status-active i  { color: #4ade80; }
.crm-status-inactive i { color: #f87171; }

.crm-profile-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.crm-profile-actions .btn {
    border-radius: 6px;
    font-weight: 500;
    padding: 7px 14px;
}
.crm-profile-actions .btn-default {
    background: rgba(255,255,255,0.95);
    border: none;
    color: #4f46e5;
}
.crm-profile-actions .btn-default:hover {
    background: #fff;
    color: #4338ca;
}

/* ---------- KPI strip ---------- */
.crm-kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1px;
    background: #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
}

.crm-kpi {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: #fff;
    transition: background 0.15s ease;
}
.crm-kpi:hover { background: #f8fafc; }

.crm-kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}

.crm-kpi-blue   .crm-kpi-icon { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.crm-kpi-green  .crm-kpi-icon { background: linear-gradient(135deg, #10b981, #059669); }
.crm-kpi-red    .crm-kpi-icon { background: linear-gradient(135deg, #ef4444, #dc2626); }
.crm-kpi-indigo .crm-kpi-icon { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.crm-kpi-purple .crm-kpi-icon { background: linear-gradient(135deg, #a855f7, #7c3aed); }

.crm-kpi-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.crm-kpi-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}
.crm-kpi-value {
    font-size: 17px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
    word-break: break-word;
}

/* ---------- Info Grid ---------- */
.crm-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0;
    background: #f8fafc;
}

.crm-info-card {
    background: #fff;
    border-right: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    padding: 0;
}
.crm-info-card:last-child { border-right: none; }

.crm-info-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.crm-info-card-header i {
    color: #4f46e5;
    font-size: 14px;
}

.crm-info-card-body {
    padding: 16px 20px;
}

.crm-info-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px dashed #e2e8f0;
}
.crm-info-row:last-child { border-bottom: none; }
.crm-info-row:first-child { padding-top: 4px; }

.crm-info-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #eef2ff;
    color: #4f46e5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.crm-info-content {
    flex: 1;
    min-width: 0;
}

.crm-info-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}

.crm-info-value {
    font-size: 14px;
    color: #0f172a;
    font-weight: 500;
    word-break: break-word;
}
.crm-info-value a {
    color: #4f46e5;
    text-decoration: none;
}
.crm-info-value a:hover {
    color: #4338ca;
    text-decoration: underline;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .crm-profile-header { padding: 18px; gap: 14px; }
    .crm-profile-avatar { width: 56px; height: 56px; font-size: 20px; }
    .crm-profile-name { font-size: 18px; }
    .crm-profile-actions { width: 100%; }
    .crm-info-card { border-right: none; }
}

/* ---------- Print friendliness ---------- */
@media print {
    .crm-contact-profile { box-shadow: none; border: 1px solid #ccc; }
    .crm-profile-header { background: #4f46e5 !important; -webkit-print-color-adjust: exact; }
    .crm-profile-actions { display: none; }
}

/* ==========================================================================
   CRM Tabs + Tables
   ========================================================================== */
.crm-tabs-wrapper {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.06);
    margin-top: 20px;
}

.crm-tabs-wrapper > .nav-tabs {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 8px;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
}

.crm-tabs-wrapper > .nav-tabs > li {
    margin-bottom: -1px;
    float: none;
    flex: 1 1 auto;
}

.crm-tabs-wrapper > .nav-tabs > li > a {
    border: none !important;
    background: transparent !important;
    color: #64748b !important;
    font-weight: 600;
    font-size: 13px;
    padding: 14px 18px;
    border-radius: 0 !important;
    border-bottom: 3px solid transparent !important;
    transition: all 0.18s ease;
    text-transform: none;
    letter-spacing: 0.2px;
    margin: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.crm-tabs-wrapper > .nav-tabs > li > a:hover {
    color: #4f46e5 !important;
    background: rgba(79, 70, 229, 0.04) !important;
    border-bottom-color: rgba(79, 70, 229, 0.3) !important;
}

.crm-tabs-wrapper > .nav-tabs > li.active > a,
.crm-tabs-wrapper > .nav-tabs > li.active > a:hover,
.crm-tabs-wrapper > .nav-tabs > li.active > a:focus {
    color: #4f46e5 !important;
    background: #fff !important;
    border-bottom: 3px solid #4f46e5 !important;
}

.crm-tabs-wrapper > .nav-tabs > li > a > i {
    font-size: 14px;
    color: inherit;
}

.crm-tabs-wrapper > .tab-content {
    padding: 20px;
    background: #fff;
}

/* Date range / filter inputs in tabs */
.crm-tabs-wrapper .form-control {
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    box-shadow: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.crm-tabs-wrapper .form-control:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* DataTables toolbar buttons */
.crm-tabs-wrapper .dt-buttons .btn,
.crm-tabs-wrapper .dataTables_wrapper .btn {
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    transition: all 0.15s ease;
}
.crm-tabs-wrapper .dt-buttons .btn:hover,
.crm-tabs-wrapper .dataTables_wrapper .btn:hover {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
}
.crm-tabs-wrapper .dt-buttons .btn i,
.crm-tabs-wrapper .dataTables_wrapper .btn i { margin-right: 4px; }

/* Search box */
.crm-tabs-wrapper .dataTables_filter input {
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    padding: 6px 12px;
    margin-left: 8px;
    min-width: 220px;
}
.crm-tabs-wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* Length / info text */
.crm-tabs-wrapper .dataTables_length select {
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    padding: 4px 8px;
}
.crm-tabs-wrapper .dataTables_info,
.crm-tabs-wrapper .dataTables_length label,
.crm-tabs-wrapper .dataTables_filter label {
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
}

/* Tables */
.crm-tabs-wrapper table.table {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    border-collapse: separate;
    border-spacing: 0;
}
.crm-tabs-wrapper table.table > thead > tr > th {
    background: #f8fafc;
    color: #334155;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid #e2e8f0;
    border-top: none;
    padding: 12px 14px;
    white-space: nowrap;
}
.crm-tabs-wrapper table.table > tbody > tr > td {
    padding: 12px 14px;
    font-size: 13px;
    color: #0f172a;
    border-top: 1px solid #f1f5f9;
    vertical-align: middle;
}
.crm-tabs-wrapper table.table > tbody > tr:hover > td {
    background: #f8fafc;
}
.crm-tabs-wrapper table.table-striped > tbody > tr:nth-of-type(odd) > td {
    background: #fcfcfd;
}
.crm-tabs-wrapper table.table-striped > tbody > tr:nth-of-type(odd):hover > td {
    background: #f1f5f9;
}

/* Status pill badges (Received / Due / Paid) inside tables */
.crm-tabs-wrapper table .label,
.crm-tabs-wrapper table .badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.4;
}
.crm-tabs-wrapper table .label-success,
.crm-tabs-wrapper table .bg-green { background: #dcfce7 !important; color: #166534 !important; }
.crm-tabs-wrapper table .label-warning,
.crm-tabs-wrapper table .bg-yellow { background: #fef3c7 !important; color: #92400e !important; }
.crm-tabs-wrapper table .label-danger,
.crm-tabs-wrapper table .bg-red { background: #fee2e2 !important; color: #991b1b !important; }
.crm-tabs-wrapper table .label-info,
.crm-tabs-wrapper table .bg-aqua { background: #dbeafe !important; color: #1e40af !important; }
.crm-tabs-wrapper table .label-default,
.crm-tabs-wrapper table .bg-gray { background: #e2e8f0 !important; color: #475569 !important; }

/* Footer total rows */
.crm-tabs-wrapper table.table > tfoot > tr > th,
.crm-tabs-wrapper table.table > tfoot > tr > td {
    background: #f8fafc;
    font-weight: 700;
    color: #0f172a;
    border-top: 2px solid #e2e8f0;
    padding: 12px 14px;
    font-size: 13px;
}

/* Pagination */
.crm-tabs-wrapper .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    margin: 0 2px;
    padding: 6px 12px !important;
    border: 1px solid #e2e8f0 !important;
    color: #475569 !important;
    background: #fff !important;
    font-size: 13px;
}
.crm-tabs-wrapper .dataTables_paginate .paginate_button:hover {
    background: #f1f5f9 !important;
    color: #4f46e5 !important;
    border-color: #cbd5e1 !important;
}
.crm-tabs-wrapper .dataTables_paginate .paginate_button.current,
.crm-tabs-wrapper .dataTables_paginate .paginate_button.current:hover {
    background: #4f46e5 !important;
    border-color: #4f46e5 !important;
    color: #fff !important;
}

/* Section header (date filter row above tables) */
.crm-tabs-wrapper label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 6px;
}

/* Responsive tabs */
@media (max-width: 768px) {
    .crm-tabs-wrapper > .nav-tabs > li {
        flex: 1 1 50%;
    }
    .crm-tabs-wrapper > .nav-tabs > li > a {
        padding: 12px 10px;
        font-size: 12px;
    }
    .crm-tabs-wrapper > .tab-content {
        padding: 14px;
    }
}

/* ==========================================================================
   CRM User Profile (manage_user/show)
   ========================================================================== */
.crm-user-profile {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.06);
    margin-bottom: 20px;
}

.crm-user-header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 26px 28px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    flex-wrap: wrap;
}

.crm-user-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}
.crm-user-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.4);
    object-fit: cover;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}
.crm-user-status-dot {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid #fff;
    background: #94a3b8;
}
.crm-user-status-active   { background: #22c55e; }
.crm-user-status-inactive { background: #ef4444; }

.crm-user-identity { flex: 1; min-width: 240px; }
.crm-user-name {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
}
.crm-user-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}
.crm-badge-role     { background: rgba(255,255,255,0.22); }
.crm-badge-active   { background: rgba(34, 197, 94, 0.85); }
.crm-badge-inactive { background: rgba(239, 68, 68, 0.85); }

.crm-user-quick-info {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: rgba(255,255,255,0.92);
}
.crm-user-quick-info i {
    margin-right: 6px;
    opacity: 0.85;
}
.crm-user-quick-info a {
    color: #fff;
    text-decoration: none;
    border-bottom: 1px dashed rgba(255,255,255,0.4);
}
.crm-user-quick-info a:hover {
    border-bottom-color: #fff;
}

.crm-user-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crm-user-actions .btn-default {
    background: rgba(255,255,255,0.95);
    border: none;
    color: #4f46e5;
    border-radius: 6px;
    font-weight: 600;
    padding: 8px 16px;
}
.crm-user-actions .btn-default:hover {
    background: #fff;
    color: #4338ca;
}

/* Force the user profile KPI strip to match contact page */
.crm-user-profile .crm-kpi-strip {
    border-top: 1px solid #e2e8f0;
    border-bottom: 0;
}

/* 3-col grid variant for richer user info */
.crm-info-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 0;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

@media (max-width: 768px) {
    .crm-user-header { padding: 18px; gap: 14px; }
    .crm-user-avatar { width: 72px; height: 72px; }
    .crm-user-name { font-size: 20px; }
    .crm-user-actions { width: 100%; }
}

@media print {
    .crm-user-header { background: #4f46e5 !important; -webkit-print-color-adjust: exact; }
    .crm-user-actions { display: none; }
}