/* ==========================================================================
   Director TMS — Modern Design System
   Shared design tokens and reusable components.
   Page-specific layouts (dashboard grid, ship-card, etc.) live in each page.
   ========================================================================== */

:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --border: #e3e7ee;
    --text: #1e2a3a;
    --text-muted: #6b7689;
    --brand: #1a3a5c;
    --brand-hover: #2a4d75;
    --accent: #c8a96a;
    --success: #2f9e6b;
    --info: #2c7da0;
    --danger: #d64545;
    --shadow-sm: 0 1px 2px rgba(20, 30, 50, 0.04), 0 1px 3px rgba(20, 30, 50, 0.06);
    --shadow-md: 0 4px 12px rgba(20, 30, 50, 0.06), 0 2px 4px rgba(20, 30, 50, 0.04);
    --shadow-lg: 0 12px 32px rgba(20, 30, 50, 0.10), 0 4px 8px rgba(20, 30, 50, 0.05);
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

/* ---- Base ---- */
body.modern {
    margin: 0;
    background: var(--bg) !important;
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif !important;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
/* Neutralize Bootstrap 2 container/row when running modern over BS2 */
body.modern > .container { background: transparent !important; box-shadow: none !important; padding: 0 !important; border-radius: 0 !important; max-width: none !important; width: auto !important; }
body.modern > .container > .row { margin-left: 0; }

/* ---- App header ---- */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 18px 0;
    box-shadow: var(--shadow-sm);
}
.app-header .inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.app-header img.logo { height: 56px; width: auto; }
.app-header .breadcrumb-title {
    font-weight: 600; color: var(--text-muted); font-size: 14px;
    letter-spacing: 0.4px; text-transform: uppercase;
}
.app-header .right { display: flex; align-items: center; gap: 16px; }
.app-header .home-link {
    color: var(--text-muted); text-decoration: none; font-size: 14px;
    padding: 6px 12px; border-radius: 6px;
    transition: background .15s ease, color .15s ease;
}
.app-header .home-link:hover { background: #eef2f8; color: var(--brand); }

/* ---- User chip (header right) ---- */
.user-chip {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 14px 8px 8px;
    background: #f4f6f9;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 14px;
}
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px; letter-spacing: 0.4px;
}
.user-chip .name { font-weight: 600; color: var(--text); }
.user-chip .logout-link {
    color: var(--text-muted); text-decoration: none; font-size: 13px;
    padding-left: 8px;
    border-left: 1px solid var(--border);
    transition: color .15s ease;
}
.user-chip .logout-link:hover { color: var(--danger); }

/* ---- Main content shell ---- */
main.dashboard,
main.content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px 24px;
}
.page-title {
    font-size: 24px; font-weight: 700;
    margin: 0 0 24px;
    letter-spacing: -0.2px;
}

/* ---- Card ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card .card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600; font-size: 13px;
    text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--text-muted);
    background: linear-gradient(180deg, #fafbfd 0%, #f4f6f9 100%);
    border-radius: var(--radius) var(--radius) 0 0;
}
.card .card-body { padding: 8px; }

/* ---- Buttons ---- */
.btn-modern {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; font-size: 14px; font-weight: 600;
    border-radius: var(--radius-sm); border: 1px solid transparent;
    cursor: pointer; text-decoration: none;
    transition: background .15s ease, transform .05s ease, box-shadow .15s ease, color .15s ease, border-color .15s ease;
    line-height: 1.2;
}
.btn-modern.primary { background: var(--brand); color: #fff; }
.btn-modern.primary:hover { background: var(--brand-hover); }
.btn-modern.ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-modern.ghost:hover { background: #eef2f8; color: var(--text); }
.btn-modern.danger { background: var(--danger); color: #fff; }
.btn-modern.danger:hover { background: #b53636; }

/* ---- Badges (status pills) ---- */
.badge {
    display: inline-block;
    padding: 3px 10px; font-size: 11px; font-weight: 600;
    border-radius: 999px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-success { background: #e3f5ec; color: #1c6f47; }
.badge-info    { background: #e6f0f7; color: #155576; }
.badge-danger  { background: #fde6e6; color: #8a2020; }
.badge-neutral { background: #eef2f8; color: #4a5b75; }

/* ---- Alert banner ---- */
.alert-banner {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    border: 1px solid;
    font-size: 14px;
}
.alert-banner.error   { background: #fff5f5; border-color: #fbb;     color: #8a2020; }
.alert-banner.info    { background: #eef6fc; border-color: #b9d8ed;  color: #1a4a73; }
.alert-banner.success { background: #e9f7f0; border-color: #b8e5cd;  color: #1c6f47; }
.alert-banner.warning { background: #fff8e6; border-color: #f1d99a;  color: #7a5a00; }

/* ---- Search panel (used by trace, address book, etc.) ---- */
.search-panel { padding: 20px; margin-bottom: 24px; }
.search-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 14px; }
@media (max-width: 900px) { .search-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) { .search-grid { grid-template-columns: 1fr; } }
.search-grid .field { display: flex; flex-direction: column; gap: 4px; }
.search-grid label {
    font-size: 11px; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.6px;
}
.search-grid input[type="text"],
.input-modern {
    width: 100%; box-sizing: border-box;
    padding: 9px 12px; font-size: 14px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease;
    font-family: inherit;
}
.search-grid input[type="text"]:focus,
.input-modern:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(26, 58, 92, 0.12);
}
.search-actions {
    display: flex; gap: 10px; margin-top: 16px;
    justify-content: flex-end; align-items: center;
}

/* ---- Result summary line ---- */
.result-summary {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; gap: 16px; flex-wrap: wrap;
}
.result-summary .count { font-size: 14px; color: var(--text-muted); }
.result-summary .count strong { color: var(--text); font-size: 16px; font-weight: 600; }

/* ---- Pagination ---- */
.pagination {
    display: flex; justify-content: center; gap: 6px;
    margin: 28px 0 8px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 38px; height: 38px; padding: 0 12px;
    font-size: 14px; font-weight: 600; text-decoration: none;
    border: 1px solid var(--border);
    background: #fff; color: var(--text);
    border-radius: var(--radius-sm);
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.pagination a:hover { background: #eef2f8; border-color: var(--brand); color: var(--brand); }
.pagination span.current { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---- Modal nudges (used over BS2 .modal) ---- */
.modern .modal { border-radius: var(--radius); border: none; box-shadow: 0 24px 64px rgba(20, 30, 50, 0.25); }
.modern .modal-header { border-bottom: 1px solid var(--border); padding: 16px 20px; background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; }
.modern .modal-header h3 { font-size: 17px; margin: 0; font-weight: 600; }
.modern .modal-header .close { font-size: 24px; opacity: 0.5; }
.modern .modal-footer { background: #fafbfd; border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); }

/* ---- jQuery UI datepicker ---- */
.ui-datepicker {
    font-family: 'Inter', sans-serif !important;
    font-size: 13px;
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-sm);
}

/* ---- Footer ---- */
.app-footer {
    max-width: 1200px;
    margin: 32px auto 0;
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12.5px;
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px;
}
.app-footer a {
    color: var(--text-muted); text-decoration: none;
    transition: color .15s ease;
}
.app-footer a:hover { color: var(--brand); text-decoration: underline; }
