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

:root {
    /* Refreshed palette: deeper navy, warmer canvas, crisper accents */
    --bg: #f5f6fa;
    --surface: #ffffff;
    --border: #e4e8f0;
    --text: #17202e;
    --text-muted: #647082;
    --brand: #16385e;
    --brand-hover: #24507f;
    --accent: #c99f4e;
    --success: #1f9d61;
    --info: #2b7fb0;
    --danger: #d43f3f;
    --sidebar-bg: linear-gradient(180deg, #142f4e 0%, #0e2138 100%);
    --sidebar-w: 236px;
    --shadow-sm: 0 1px 2px rgba(16, 26, 46, 0.05), 0 1px 3px rgba(16, 26, 46, 0.07);
    --shadow-md: 0 5px 14px rgba(16, 26, 46, 0.08), 0 2px 4px rgba(16, 26, 46, 0.05);
    --shadow-lg: 0 14px 36px rgba(16, 26, 46, 0.12), 0 4px 10px rgba(16, 26, 46, 0.06);
    --radius: 14px;
    --radius-sm: 9px;
}

* { 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; }


/* ==========================================================================
   APP SHELL — persistent sidebar navigation (redesign)
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; }

.side-nav {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: #cfd9e6;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.side-brand { padding: 18px 16px 14px; }
.side-brand a { display: block; background: #fff; border-radius: 10px; padding: 10px 12px; }
.side-brand img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.side-links { flex: 1; padding: 8px 12px; overflow-y: auto; }
.side-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: #b9c6d6; text-decoration: none;
    font-size: 14px; font-weight: 500;
    transition: background .15s ease, color .15s ease;
}
.side-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.side-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-link.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.side-link.active svg { opacity: 1; }

.side-footer { padding: 14px 16px 18px; border-top: 1px solid rgba(255,255,255,.10); }
.lang-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    color: #b9c6d6; text-decoration: none; font-size: 13px;
    padding: 6px 8px; border-radius: var(--radius-sm);
    margin-bottom: 10px;
    transition: background .15s ease, color .15s ease;
}
.lang-toggle svg { width: 15px; height: 15px; }
.lang-toggle:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.side-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent); color: #1a2636;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}
.side-user-meta .n { color: #fff; font-size: 13px; font-weight: 600; line-height: 1.2; }
.side-user-meta .a { color: #93a3b5; font-size: 11.5px; }
.side-logout {
    display: block; text-align: center;
    padding: 8px; border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,.18);
    color: #cfd9e6; text-decoration: none; font-size: 13px;
    transition: background .15s ease, color .15s ease;
}
.side-logout:hover { background: rgba(255,255,255,.10); color: #fff; }

.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex; align-items: center; gap: 14px;
    box-shadow: var(--shadow-sm);
    position: sticky; top: 0; z-index: 950;
}
.top-title { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; color: var(--text); }
.burger {
    display: none;
    background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 7px 9px; cursor: pointer; color: var(--text);
}
.burger svg { width: 18px; height: 18px; display: block; }

.shell-main .content { flex: 1; max-width: 1280px; width: 100%; margin: 0 auto; padding: 28px 28px 20px; }
.shell-main .app-footer { max-width: 1280px; width: 100%; margin: 0 auto; }

.side-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(14, 24, 40, .45); z-index: 990;
}

@media (max-width: 980px) {
    .side-nav {
        position: fixed; left: calc(-1 * var(--sidebar-w) - 10px); top: 0; z-index: 1000;
        transition: left .22s ease;
        box-shadow: var(--shadow-lg);
    }
    .side-nav.open { left: 0; }
    .side-backdrop.open { display: block; }
    .burger { display: inline-flex; }
    .shell-main .content { padding: 20px 16px 16px; }
}
