/* ============================================
   FRIENDLY FREIGHT NETWORK TMS — Stylesheet
   ============================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0efe9;
    min-height: 100vh;
    color: #1a1a1a;
    font-size: 14px;
    line-height: 1.5;
}


/* ============================================
   LOGIN PAGE
   ============================================ */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    border: 0.5px solid #ddddd5;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

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

.login-logo {
    width: 220px;
    height: auto;
    margin: 0 auto 12px;
    display: block;
}

.login-header p {
    font-size: 14px;
    color: #666;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddddd5;
    border-radius: 8px;
    font-size: 14px;
    color: #1a1a1a;
    background: #fafafa;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-group input:focus {
    border-color: #185FA5;
    box-shadow: 0 0 0 3px rgba(24,95,165,0.12);
    background: white;
}

#login-btn {
    width: 100%;
    padding: 11px;
    background: #185FA5;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 4px;
}

#login-btn:hover  { background: #0C447C; }
#login-btn:disabled { background: #aaa; cursor: not-allowed; }

#message-box {
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
    line-height: 1.5;
}

#message-box.error {
    background: #FCEBEB;
    border: 0.5px solid #F09595;
    color: #A32D2D;
}

#message-box.success {
    background: #EAF3DE;
    border: 0.5px solid #C0DD97;
    color: #3B6D11;
}

.hidden { display: none !important; }

.login-footer {
    text-align: center;
    margin-top: 20px;
}

.login-footer a {
    font-size: 13px;
    color: #185FA5;
    text-decoration: none;
}

.login-footer a:hover { text-decoration: underline; }


/* ============================================
   DASHBOARD LAYOUT
   Three-part layout: top bar + sidebar + content
   ============================================ */

/* The whole page sits in this wrapper */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- TOP BAR ---
   Fixed across the top. Sits above everything. */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: white;
    border-bottom: 0.5px solid #ddddd5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

.top-bar-logo {
    height: 32px;
    width: auto;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-bar-user {
    font-size: 13px;
    color: #555;
}

.top-bar-role {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
    background: #E6F1FB;
    color: #185FA5;
    border: 0.5px solid #B5D4F4;
    text-transform: capitalize;
}

.signout-btn {
    padding: 7px 14px;
    background: white;
    border: 0.5px solid #ddddd5;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    color: #333;
    transition: background 0.2s;
}

.signout-btn:hover { background: #f5f5f0; }


/* --- SIDEBAR ---
   Fixed on the left. Scrolls independently if needed. */
.sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 220px;
    background: white;
    border-right: 0.5px solid #ddddd5;
    padding: 20px 0;
    overflow-y: auto;
    z-index: 90;
}

.sidebar-section-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #aaa;
    padding: 16px 20px 6px;
}

/* Each link in the sidebar */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    font-size: 13px;
    color: #444;
    text-decoration: none;
    border-radius: 0;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.sidebar-link:hover {
    background: #f5f5f0;
    color: #1a1a1a;
}

/* The currently active/selected page link */
.sidebar-link.active {
    background: #EBF3FC;
    color: #185FA5;
    font-weight: 500;
}

.sidebar-link.active .nav-icon { opacity: 1; }

/* Small icon next to each nav item */
.nav-icon {
    width: 16px;
    height: 16px;
    opacity: 0.5;
    flex-shrink: 0;
}

.sidebar-link.active .nav-icon,
.sidebar-link:hover .nav-icon { opacity: 1; }


/* --- MAIN CONTENT AREA ---
   Pushed right by the sidebar, pushed down by the top bar. */
.main-content {
    margin-left: 220px;
    margin-top: 60px;
    padding: 36px 40px;
    flex: 1;
    min-height: calc(100vh - 60px);
}

.page-title {
    font-size: 22px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 14px;
    color: #888;
    margin-bottom: 32px;
}


/* ============================================
   DASHBOARD SUMMARY CARDS
   The row of numbers at the top of the dashboard
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 36px;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 20px 22px;
    border: 0.5px solid #ddddd5;
}

.stat-label {
    font-size: 12px;
    color: #888;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1;
}

.stat-sub {
    font-size: 12px;
    color: #aaa;
    margin-top: 4px;
}


/* ============================================
   CONTENT CARDS
   White boxes used throughout the app
   ============================================ */

.card {
    background: white;
    border-radius: 10px;
    border: 0.5px solid #ddddd5;
    margin-bottom: 20px;
}

.card-header {
    padding: 16px 22px;
    border-bottom: 0.5px solid #f0efe9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
}

.card-body {
    padding: 22px;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: #aaa;
    font-size: 13px;
}

.empty-state p:first-child {
    font-size: 15px;
    font-weight: 500;
    color: #ccc;
    margin-bottom: 6px;
}


/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    border: 0.5px solid #ddddd5;
    background: white;
    color: #333;
    text-decoration: none;
}

.btn:hover { background: #f5f5f0; }

.btn-primary {
    background: #185FA5;
    color: white;
    border-color: #185FA5;
}

.btn-primary:hover { background: #0C447C; border-color: #0C447C; }


/* ============================================
   LOADING SPINNER
   Shows while we wait for data
   ============================================ */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: #aaa;
    font-size: 13px;
    gap: 10px;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #e0e0e0;
    border-top-color: #185FA5;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }


/* ============================================
   LOADS PAGE
   ============================================ */

.page-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
}

/* Filter buttons row */
.filter-bar {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 6px 14px;
    border-radius: 20px;
    border: 0.5px solid #ddddd5;
    background: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    color: #555;
    transition: all 0.15s;
}

.filter-btn:hover  { background: #f5f5f0; }
.filter-btn.active { background: #185FA5; color: white; border-color: #185FA5; }


/* ---- LOADS TABLE ---- */
.table-scroll {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead tr {
    border-bottom: 0.5px solid #ebebE3;
}

.data-table th {
    text-align: left;
    padding: 11px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    white-space: nowrap;
}

.data-table td {
    padding: 13px 16px;
    border-bottom: 0.5px solid #f5f5f0;
    color: #333;
    white-space: nowrap;
}

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

.load-number {
    font-weight: 600;
    color: #185FA5;
    font-size: 13px;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
}

.status-pending    { background: #FAEEDA; color: #854F0B; }
.status-dispatched { background: #E6F1FB; color: #185FA5; }
.status-in-transit { background: #EEEDFE; color: #533AB7; }
.status-delivered  { background: #EAF3DE; color: #3B6D11; }
.status-invoiced   { background: #f0efe9; color: #666;    }

/* Margin colors in table */
.margin-pos { color: #3B6D11; font-weight: 500; }
.margin-neg { color: #A32D2D; font-weight: 500; }


/* ============================================
   MODAL (NEW / EDIT LOAD FORM)
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}

.modal {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 680px;
    border: 0.5px solid #ddddd5;
    position: relative;
}

.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 0.5px solid #f0efe9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
    color: #1a1a1a;
}

.modal-close {
    background: none;
    border: none;
    font-size: 16px;
    color: #aaa;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
    line-height: 1;
}

.modal-close:hover { background: #f5f5f0; color: #333; }

.modal-body {
    padding: 22px 24px;
    max-height: 65vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 0.5px solid #f0efe9;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Section labels inside the form */
.form-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #aaa;
    margin: 20px 0 10px;
}

.form-section-label:first-child { margin-top: 0; }

/* Row of form fields side by side */
.form-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.form-row .form-group          { flex: 1; min-width: 140px; }
.form-row .form-group-sm       { flex: 0 0 80px; min-width: 80px; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #555;
    margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ddddd5;
    border-radius: 8px;
    font-size: 13px;
    color: #1a1a1a;
    background: #fafafa;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #185FA5;
    box-shadow: 0 0 0 3px rgba(24,95,165,0.1);
    background: white;
}

.form-group textarea { resize: vertical; }

/* Required field asterisk */
.required { color: #A32D2D; }

/* Live margin display box */
.margin-display {
    padding: 9px 12px;
    border: 1px solid #ddddd5;
    border-radius: 8px;
    font-size: 13px;
    background: #fafafa;
    color: #888;
    min-height: 38px;
    display: flex;
    align-items: center;
}


/* ============================================
   CUSTOMERS & CARRIERS PAGES
   ============================================ */

.search-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 8px 14px;
    border: 1px solid #ddddd5;
    border-radius: 8px;
    font-size: 13px;
    color: #1a1a1a;
    background: white;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    border-color: #185FA5;
    box-shadow: 0 0 0 3px rgba(24,95,165,0.1);
}


/* ============================================
   CARRIERS PAGE
   ============================================ */

/* Insurance expiry warning banner */
.expiry-banner, #expiry-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #FAEEDA;
    border: 0.5px solid #FAC775;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
    color: #854F0B;
    margin-bottom: 16px;
    line-height: 1.5;
}

/* Red text for expired insurance dates in the table */
.expiry-expired {
    color: #A32D2D;
    font-weight: 500;
}

/* Amber text for insurance expiring soon */
.expiry-soon {
    color: #854F0B;
    font-weight: 500;
}


/* ============================================
   SETTINGS PAGE
   ============================================ */

.settings-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #aaa;
    margin: 0 0 10px;
}

/* Role permission guide cards */
.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.role-card {
    border: 0.5px solid #ddddd5;
    border-radius: 10px;
    padding: 16px;
}

.role-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.role-desc {
    font-size: 12px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 12px;
}

.role-access {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.access-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 20px;
}

.access-yes { background: #EAF3DE; color: #3B6D11; }
.access-no  { background: #f5f5f0; color: #bbb;    }

/* Role pills in the users table */
.role-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    text-transform: capitalize;
}

.role-admin      { background: #EEEDFE; color: #533AB7; }
.role-dispatcher { background: #E6F1FB; color: #185FA5; }
.role-accounting { background: #EAF3DE; color: #3B6D11; }


/* ============================================
   LOAD STATUS QUICK-CHANGE BUTTON
   ============================================ */

.status-change-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s;
}

.status-change-btn:hover { opacity: 0.8; }

/* Status update modal */
.status-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #ddddd5;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-size: 13px;
}

.status-option:hover           { background: #fafaf7; border-color: #c0c0b5; }
.status-option.selected        { border-color: #185FA5; background: #E6F1FB; }
.status-option:last-child      { margin-bottom: 0; }
.status-option .status-dot     { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }


/* ============================================
   LOAD DETAIL PAGE
   ============================================ */

.detail-header {
    margin-bottom: 24px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #185FA5;
    text-decoration: none;
    margin-bottom: 12px;
}

.back-link:hover { text-decoration: underline; }

.detail-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 900px) {
    .detail-grid { grid-template-columns: 1fr; }
}

.detail-card { margin-bottom: 0; }
.detail-left, .detail-right { display: flex; flex-direction: column; gap: 16px; }

.detail-field {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 0.5px solid #f5f5f0;
    font-size: 13px;
    gap: 12px;
}

.detail-field:last-child { border-bottom: none; }

.detail-label {
    color: #888;
    flex-shrink: 0;
    font-size: 12px;
}

.detail-value {
    color: #1a1a1a;
    text-align: right;
    font-weight: 500;
}

/* Route visual */
.route-stop {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.route-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-top: 3px;
    flex-shrink: 0;
}

.route-dot-pickup   { background: #185FA5; }
.route-dot-stop2    { background: #F2A623; }
.route-dot-delivery { background: #3B6D11; }

.route-line {
    width: 2px;
    height: 24px;
    background: #e0e0d8;
    margin: 4px 0 4px 5px;
}

.route-stop-label    { font-size: 11px; font-weight: 600; color: #aaa; text-transform: uppercase; letter-spacing: 0.05em; }
.route-stop-location { font-size: 14px; font-weight: 500; color: #1a1a1a; margin: 2px 0; }
.route-stop-date     { font-size: 12px; color: #888; }

/* Financials grid */
.finance-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.finance-item {
    background: #fafafa;
    border: 0.5px solid #ebebE3;
    border-radius: 8px;
    padding: 12px 14px;
}

.finance-label { font-size: 11px; color: #aaa; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.finance-value { font-size: 18px; font-weight: 600; color: #1a1a1a; }

/* Status history timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }

.timeline-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 0.5px solid #f5f5f0;
}

.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 4px;
    flex-shrink: 0;
}

.timeline-status { font-size: 13px; color: #333; margin-bottom: 2px; }
.timeline-note   { font-size: 12px; color: #666; margin-bottom: 2px; font-style: italic; }
.timeline-time   { font-size: 11px; color: #aaa; }

/* Problem load badge */
.problem-badge {
    background: #FAEEDA;
    border: 0.5px solid #FAC775;
    color: #854F0B;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.problem-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #FAEEDA;
    color: #854F0B;
    font-size: 10px;
    font-weight: 700;
    margin-left: 6px;
    vertical-align: middle;
}

/* Load number link in table */
.load-number-link {
    font-weight: 600;
    color: #185FA5;
    text-decoration: none;
    font-size: 13px;
}

.load-number-link:hover { text-decoration: underline; }


/* ============================================
   ADVANCED FILTERS PANEL
   ============================================ */

.loads-filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.adv-filter-panel {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    background: white;
    border: 0.5px solid #ddddd5;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 12px;
    align-items: flex-end;
}

.adv-filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 160px;
}

.adv-filter-group label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #aaa;
}

.adv-filter-group select,
.adv-filter-group input {
    padding: 7px 10px;
    border: 1px solid #ddddd5;
    border-radius: 8px;
    font-size: 13px;
    color: #1a1a1a;
    background: #fafafa;
    outline: none;
}

.adv-filter-group select:focus,
.adv-filter-group input:focus {
    border-color: #185FA5;
    box-shadow: 0 0 0 3px rgba(24,95,165,0.1);
}


/* ============================================
   LOCATION PAGES + LOAD DETAIL EDIT MODE
   ============================================ */

/* Edit mode field layout */
.detail-field.edit-field {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}

/* Delete button */
.btn-danger {
    color: #A32D2D;
    border-color: #F09595;
}

.btn-danger:hover {
    background: #FCEBEB;
}
