/* ============================================================
   CRM — admin.css  (Responsive, Mobile-First)
   ============================================================ */

/* ---- Reset / Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
    background: #f0f2f5;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1f2937;
    margin: 0; padding: 0;
}

/* Fix Bootstrap's input max-width conflict everywhere */
input[type=text], input[type=password], input[type=email],
input[type=number], select, textarea {
    width: 100%; max-width: 100%;
    padding: 8px 11px;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    font-size: 14px;
    color: #1f2937;
    background: #fff;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}
textarea { resize: vertical; min-height: 70px; max-height: none; }

a { color: #2563eb; }
a:hover { color: #1d4ed8; text-decoration: none; }

/* ---- Wrapper ---- */
#wrapper { width: 100%; overflow-x: hidden; }

/* ============================================================
   TOP NAVBAR
   ============================================================ */
.navbar-static-top {
    height: auto !important;
    min-height: 50px;
    background: #1e293b !important;
    border: none !important;
    border-radius: 0 !important;
    margin-bottom: 0 !important;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.navbar-header {
    background: #1e293b;
    display: flex;
    align-items: center;
    padding: 0 12px;
    height: 50px;
    position: relative;
}
.navbar-brand {
    color: #fff !important;
    font-weight: 700;
    font-size: 18px;
    padding: 0 !important;
    line-height: 50px;
}
.navbar-toggle {
    background: rgba(255,255,255,.1) !important;
    border-color: rgba(255,255,255,.2) !important;
    border-radius: 6px !important;
    margin: 0 10px 0 0 !important;
    padding: 6px 10px !important;
    float: none;
}
.navbar-toggle .icon-bar { background: #fff !important; }

/* ---- Top right actions (profile / logout) ---- */
.navbar-right-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 8px;
}
.navbar-right-actions a {
    color: rgba(255,255,255,.8);
    font-size: 13px;
    padding: 5px 10px;
    border-radius: 6px;
    white-space: nowrap;
    display: flex; align-items: center; gap: 5px;
}
.navbar-right-actions a:hover { background: rgba(255,255,255,.1); color: #fff; }
.navbar-right-actions .fa { font-size: 14px; }

/* Hide "Create Customer" text on tiny screens, show icon only */
.navbar-right-actions .btn-label { display: none; }
@media (min-width: 480px) { .navbar-right-actions .btn-label { display: inline; } }

/* ---- Search bar in top nav ---- */
.customer_search {
    background: #1e293b;
    padding: 6px 12px;
    position: relative;
}
.customer_search input {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 20px;
    color: #fff;
    padding: 6px 14px;
    font-size: 13px;
    height: 34px;
}
.customer_search input::placeholder { color: rgba(255,255,255,.5); }
.customer_search input:focus { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.4); box-shadow: none; }
.customer_search #srch_result {
    position: absolute;
    top: 46px; left: 12px;
    width: calc(100% - 24px);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    z-index: 999;
    max-height: 60vh;
    overflow-y: auto;
}
span.close_srch {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    font-weight: bold; color: rgba(255,255,255,.6);
    cursor: pointer; padding: 2px 7px; font-size: 14px;
}

/* ============================================================
   SIDEBAR NAVIGATION
   ============================================================ */
.sidebar {
    background: #1e293b;
    min-height: calc(100vh - 50px);
    padding: 0 !important;
}

/* Mobile: sidebar hidden, toggled by hamburger */
@media (max-width: 767px) {
    .sidebar {
        display: none;
        position: fixed;
        top: 50px; left: 0;
        width: 260px;
        height: calc(100vh - 50px);
        z-index: 1020;
        overflow-y: auto;
        box-shadow: 4px 0 16px rgba(0,0,0,.3);
    }
    .sidebar.open { display: block; }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 50px; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,.4);
        z-index: 1010;
    }
    .sidebar-overlay.open { display: block; }
}

/* Sidebar nav list */
.navbar-static-side { width: 100%; }
.sidebar-collapse { padding: 8px 0; }
#side-menu, #side-menu ul { list-style: none; margin: 0; padding: 0; }
#side-menu > li > a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    color: rgba(255,255,255,.75);
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .15s;
}
#side-menu > li > a:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
    border-left-color: #3b82f6;
}
#side-menu > li.active > a {
    color: #fff;
    background: rgba(59,130,246,.2);
    border-left-color: #3b82f6;
}
#side-menu > li > a .fa { width: 18px; text-align: center; font-size: 15px; }
.fa.arrow { display: none; } /* hide submenu arrows for now */

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
#page-wrapper {
    min-height: calc(100vh - 50px);
    background: #fff;
    padding: 20px 16px;
}
@media (min-width: 768px) {
    #page-wrapper { padding: 24px 28px; }
}

/* Flash messages */
.alert {
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    padding: 12px 16px;
    display: flex; align-items: center; gap: 10px;
}
.alert-success { background: #dcfce7; color: #14532d; border: 1px solid #bbf7d0; }
.alert-danger   { background: #fee2e2; color: #7f1d1d; border: 1px solid #fecaca; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.crm-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 2px solid #f3f4f6;
    flex-wrap: wrap;
    gap: 10px;
}
.crm-page-title {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    display: flex; align-items: center; gap: 8px;
}
.crm-page-title .fa { color: #3b82f6; }
.badge-count {
    background: #3b82f6; color: #fff;
    border-radius: 12px; padding: 2px 10px;
    font-size: 12px; font-weight: 700;
}
.crm-page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 16px;
}
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}
.filter-cell { flex: 1 1 160px; }
.filter-cell label {
    display: block;
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px;
    color: #6b7280; margin-bottom: 4px;
}
.filter-actions { display: flex; gap: 6px; align-items: flex-end; }

/* On small screens, filter items go full width */
@media (max-width: 600px) {
    .filter-cell { flex: 1 1 100%; }
    .filter-actions { width: 100%; }
    .filter-actions .btn { flex: 1; }
}

/* Active filter pills */
.filter-pills { margin-bottom: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.filter-pill {
    background: #dbeafe; color: #1d4ed8;
    border: 1px solid #bfdbfe; border-radius: 12px;
    padding: 3px 10px; font-size: 12px; font-weight: 600;
}

/* ============================================================
   BULK ASSIGN BAR
   ============================================================ */
.bulk-bar {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
}
.bulk-bar-inner {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.bulk-bar-inner select { max-width: 200px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.crm-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 700px; }
.crm-table thead th {
    background: #f9fafb;
    padding: 10px 12px;
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .5px; color: #6b7280;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}
.crm-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}
.crm-table tbody tr:hover td { background: #f0f7ff; }

/* ---- Mobile table cards ---- */
@media (max-width: 767px) {
    .crm-table { min-width: unset; }
    .crm-table thead { display: none; }
    .crm-table tbody tr {
        display: block;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        margin-bottom: 10px;
        padding: 4px 0;
        box-shadow: 0 1px 4px rgba(0,0,0,.06);
    }
    .crm-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 9px 14px;
        border-bottom: 1px solid #f3f4f6;
        font-size: 13px;
    }
    .crm-table tbody td:last-child { border-bottom: none; }
    .crm-table tbody td::before {
        content: attr(data-label);
        font-weight: 700; font-size: 11px;
        text-transform: uppercase; letter-spacing: .5px;
        color: #9ca3af;
        white-space: nowrap;
        margin-right: 12px;
        flex-shrink: 0;
    }
    .crm-table tbody td.table_action { justify-content: flex-end; }
    .crm-table tbody td.table_action::before { content: ''; }
}

/* Company name link */
.company-name a { font-weight: 600; color: #1d4ed8; }
.company-name a:hover { text-decoration: underline; }

/* ============================================================
   STATUS & BADGE PILLS
   ============================================================ */
.enquiry-status {
    display: inline-block; padding: 3px 10px; border-radius: 10px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
    white-space: nowrap;
}
.status-new          { background: #dbeafe; color: #1e40af; }
.status-contacted    { background: #fef3c7; color: #92400e; }
.status-quoted       { background: #e0f2fe; color: #075985; }
.status-won          { background: #dcfce7; color: #14532d; }
.status-lost         { background: #fee2e2; color: #7f1d1d; }
.status-negotiation  { background: #ffedd5; color: #7c2d12; }
.status-default      { background: #f3f4f6; color: #6b7280; }

.source-badge {
    display: inline-block; background: #f3e8ff; color: #6d28d9;
    border-radius: 4px; padding: 2px 7px; font-size: 11px; font-weight: 600;
}
.product-badge {
    display: inline-block; background: #ecfdf5; color: #065f46;
    border-radius: 4px; padding: 2px 7px; font-size: 11px; font-weight: 600;
}

/* ============================================================
   MOBILE CALL / WHATSAPP LINKS
   ============================================================ */
.mobile-links-wrap {
    display: inline-flex; align-items: center; gap: 6px;
    flex-wrap: wrap;
}
.mobile-num-link { color: #1f2937; font-size: 13px; font-weight: 500; }
.mobile-num-link:hover { color: #1d4ed8; }
.action-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 6px; flex-shrink: 0;
    transition: background .15s, transform .1s;
}
.action-icon:hover { transform: scale(1.1); text-decoration: none; }
.call-icon { background: #e0f2fe; color: #0369a1; font-size: 14px; }
.call-icon:hover { background: #0369a1; color: #fff; }
.wa-icon { background: #dcfce7; }
.wa-icon:hover { background: #16a34a; }
.wa-svg { width: 17px; height: 17px; fill: #16a34a; display: block; }
.wa-icon:hover .wa-svg { fill: #fff; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn { border-radius: 7px; font-size: 13px; font-weight: 600; padding: 7px 16px; transition: all .15s; }
.btn-primary   { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.btn-default:hover { background: #f3f4f6; border-color: #d1d5db; }
.btn-warning   { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-block { width: 100%; display: block; text-align: center; }

/* Table action icons */
.table_action { text-align: center; white-space: nowrap; }
.fa.fa-edit    { color: #3b82f6; font-size: 16px; }
.fa.fa-calendar{ color: #8b5cf6; font-size: 16px; }
.fa.fa-times.text-danger { color: #ef4444; font-size: 16px; }

/* ============================================================
   SIDEBAR WIDGETS (schedule)
   ============================================================ */
.widget {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
}
.widget h4 {
    font-size: 13px; font-weight: 700; color: #fff;
    background: #1e293b;
    margin: -12px -12px 12px;
    padding: 10px 14px;
    border-radius: 10px 10px 0 0;
}
.widget h4 .block { padding: 6px 0; }

/* ============================================================
   CUSTOMER EDIT FORM CARDS
   ============================================================ */
.edit-wrap { max-width: 900px; }

.form-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 16px;
    overflow: hidden;
}
.form-card-head {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    padding: 11px 18px;
    display: flex; align-items: center; gap: 8px;
}
.form-card-head h4 {
    margin: 0; font-size: 12px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px; color: #6b7280;
}
.form-card-head .fa { color: #3b82f6; font-size: 14px; }
.form-card-body { padding: 16px 18px; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
@media (max-width: 600px) { .field-grid { grid-template-columns: 1fr; } }

.fgroup { margin-bottom: 14px; }
.fgroup label { display: block; font-size: 12px; font-weight: 700; color: #374151; margin-bottom: 5px; }
.fgroup label .req { color: #ef4444; margin-left: 2px; }
.fgroup label .opt { color: #9ca3af; font-weight: 400; font-size: 11px; margin-left: 4px; }

.submit-bar {
    background: #f9fafb; border: 1px solid #e5e7eb;
    border-radius: 10px; padding: 14px 18px;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.btn-save {
    background: #2563eb; color: #fff; border: none; border-radius: 7px;
    padding: 10px 28px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: background .15s;
}
.btn-save:hover { background: #1d4ed8; }

.val-errors {
    background: #fef2f2; border: 1px solid #fecaca;
    border-radius: 8px; padding: 12px 16px;
    margin-bottom: 16px; color: #991b1b; font-size: 13px;
}
.val-errors ul { margin: 4px 0 0 16px; padding: 0; }

/* ============================================================
   USER EDIT FORM
   ============================================================ */
.user-form-wrap { max-width: 500px; }
.user-form-wrap .fgroup input[type=password] { font-family: monospace; letter-spacing: 2px; }

/* ============================================================
   DASHBOARD KPI CARDS
   ============================================================ */
.kpi-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.kpi-card {
    background: #fff; border: 1px solid #e5e7eb;
    border-radius: 10px; padding: 16px 18px;
    flex: 1 1 130px; border-top: 4px solid #3b82f6;
}
.kpi-card.kpi-won  { border-top-color: #22c55e; }
.kpi-card.kpi-lost { border-top-color: #ef4444; }
.kpi-card.kpi-month{ border-top-color: #8b5cf6; }
.kpi-card.kpi-quot { border-top-color: #06b6d4; }
.kpi-value { font-size: 32px; font-weight: 800; color: #1f2937; line-height: 1.1; }
.kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: #9ca3af; margin-top: 4px; }

/* ============================================================
   FOOTER
   ============================================================ */
.footer { margin: 12px 16px; text-align: right; font-size: 11px; color: #9ca3af; }

/* ============================================================
   MISC
   ============================================================ */
.bg_red td, tr.no-schedule td { background: #fff8f0 !important; }
.p_0 { padding-left: 0 !important; padding-right: 0 !important; }
.p_left_0  { padding-left: 0 !important; }
.p_right_0 { padding-right: 0 !important; }
img.simg { width: 60px; height: auto; max-height: 60px; }

/* Pagination */
.pagination > li > a, .pagination > li > span {
    border-radius: 6px !important;
    margin: 0 2px;
    padding: 6px 12px;
    font-size: 13px;
}

/* Schedule edit form read-only fields */
.ro_field {
    padding: 8px 11px;
    border: 1px solid #e5e7eb;
    border-radius: 7px;
    background: #f9fafb;
    min-height: 36px;
    font-size: 13px;
    color: #374151;
}
