/* =============================================
   SALES CRM - MAIN STYLESHEET
   ============================================= */

:root {
    --primary: #1a56db;
    --primary-dark: #1e429f;
    --secondary: #6366f1;
    --success: #057a55;
    --danger: #c81e1e;
    --warning: #c27803;
    --info: #0694a2;
    --dark: #111928;
    --gray: #6b7280;
    --light: #f9fafb;
    --border: #e5e7eb;
    --sidebar-width: 260px;
    --header-height: 64px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f3f4f6;
    color: #111928;
    font-size: 14px;
    line-height: 1.5;
}

/* ---- LOGIN PAGE ---- */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a56db 0%, #1e429f 50%, #0e2a73 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, #1a56db, #6366f1);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.login-logo h1 { font-size: 22px; font-weight: 700; color: #111928; }
.login-logo p { font-size: 13px; color: #6b7280; }

/* ---- LAYOUT ---- */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: #111928;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform .3s;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid #1f2937;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .brand-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, #1a56db, #6366f1);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand h2 { font-size: 15px; font-weight: 700; color: #fff; }
.sidebar-brand p { font-size: 11px; color: #9ca3af; }

.sidebar-menu { padding: 12px 0; }

.menu-section {
    padding: 8px 16px 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #6b7280;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: #9ca3af;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all .15s;
    border-left: 3px solid transparent;
}

.menu-item:hover { background: #1f2937; color: #fff; border-left-color: #374151; }
.menu-item.active { background: #1e3a8a; color: #60a5fa; border-left-color: #1a56db; }
.menu-item svg { flex-shrink: 0; }

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

.topbar {
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
}

.topbar-title { font-size: 18px; font-weight: 700; color: #111928; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.page-content { padding: 24px; flex: 1; }

/* ---- CARDS ---- */
.card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header h3 { font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }

/* ---- STATS GRID ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
}

.stat-card .stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 12px;
}

.stat-card .stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-card .stat-label { font-size: 12px; color: var(--gray); margin-top: 4px; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: #111928;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: #1a56db;
    box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.form-control:disabled { background: #f9fafb; color: #9ca3af; }
.form-control.is-invalid { border-color: var(--danger); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all .15s;
    white-space: nowrap;
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

.btn-primary { background: #1a56db; color: #fff; }
.btn-primary:hover { background: #1e429f; }
.btn-success { background: #057a55; color: #fff; }
.btn-success:hover { background: #046c4e; }
.btn-danger { background: #c81e1e; color: #fff; }
.btn-danger:hover { background: #9b1c1c; }
.btn-warning { background: #c27803; color: #fff; }
.btn-warning:hover { background: #9f580a; }
.btn-info { background: #0694a2; color: #fff; }
.btn-info:hover { background: #047481; }
.btn-secondary { background: #f3f4f6; color: #374151; border: 1px solid var(--border); }
.btn-secondary:hover { background: #e5e7eb; }
.btn-outline-primary { background: transparent; color: #1a56db; border: 1.5px solid #1a56db; }
.btn-outline-primary:hover { background: #1a56db; color: #fff; }

/* ---- BADGES ---- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-success { background: #def7ec; color: #057a55; }
.badge-danger { background: #fde8e8; color: #c81e1e; }
.badge-warning { background: #fdf6b2; color: #c27803; }
.badge-info { background: #e1effe; color: #1a56db; }
.badge-gray { background: #f3f4f6; color: #6b7280; }
.badge-purple { background: #edebfe; color: #7e3af2; }

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; }

table.data-table { width: 100%; border-collapse: collapse; }
table.data-table th {
    background: #f9fafb;
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6b7280;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13.5px;
    vertical-align: middle;
}

table.data-table tr:hover td { background: #f9fafb; }
table.data-table tr:last-child td { border-bottom: none; }

/* ---- ALERTS ---- */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13.5px;
}

.alert-success { background: #def7ec; color: #057a55; border: 1px solid #bcf0da; }
.alert-danger { background: #fde8e8; color: #c81e1e; border: 1px solid #f8b4b4; }
.alert-warning { background: #fdf6b2; color: #c27803; border: 1px solid #fce96a; }
.alert-info { background: #e1effe; color: #1a56db; border: 1px solid #a4cafe; }

/* ---- PHOTO UPLOAD ---- */
.photo-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }

.photo-slot {
    aspect-ratio: 1;
    border: 2px dashed var(--border);
    border-radius: 10px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    cursor: pointer;
    transition: all .15s;
    position: relative;
    overflow: hidden;
    background: #f9fafb;
}

.photo-slot:hover { border-color: #1a56db; background: #eff6ff; }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; }
.photo-slot .remove-photo {
    position: absolute; top: 4px; right: 4px;
    background: rgba(200,30,30,.85);
    color: #fff; border: none; border-radius: 50%;
    width: 22px; height: 22px;
    font-size: 12px; cursor: pointer;
    display: none;
}

.photo-slot:hover .remove-photo { display: flex; align-items: center; justify-content: center; }

/* ---- GPS FIELD ---- */
.gps-field {
    background: #f0f7ff;
    border: 1.5px solid #bfdbfe;
    border-radius: 10px;
    padding: 16px;
}

.gps-coords {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 10px;
}

/* ---- MODAL ---- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}

.modal-box {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0,0,0,.3);
}

.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}

.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 10px;
}

/* ---- USER AVATAR ---- */
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ---- FILTERS BAR ---- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 16px 20px;
    background: #f9fafb;
    border-bottom: 1px solid var(--border);
}

.filter-bar .form-control { width: auto; min-width: 140px; padding: 8px 12px; }

/* ---- PAGINATION ---- */
.pagination { display: flex; align-items: center; gap: 4px; }
.page-btn {
    width: 34px; height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 13px;
    text-decoration: none; color: #374151;
    transition: all .15s;
}

.page-btn:hover { background: #f3f4f6; }
.page-btn.active { background: #1a56db; color: #fff; border-color: #1a56db; }

/* ---- MISC ---- */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.text-muted { color: var(--gray); }
.text-sm { font-size: 12px; }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .photo-grid { grid-template-columns: repeat(3, 1fr); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
