/* ========================================================
   AGENT MODULE — ISOLATED STYLES
   Florette Relocations CRM | SF-Agent
   ======================================================== */

/* ── Design Tokens (mirrored from styles.css) ─────────── */
:root {
    --ag-primary:     #c20e1a;
    --ag-blue:        #2563eb;
    --ag-blue-hover:  #1d4ed8;
    --ag-bg:          #f8fafc;
    --ag-sidebar-bg:  #ffffff;
    --ag-sidebar-hover: #f1f5f9;
    --ag-sidebar-active: #eff6ff;
    --ag-text:        #1e293b;
    --ag-muted:       #64748b;
    --ag-border:      #e2e8f0;
    --ag-shadow-sm:   0 1px 2px 0 rgb(0 0 0 / 0.05);
    --ag-shadow-md:   0 4px 6px -1px rgb(0 0 0 / 0.1);
    --ag-shadow-lg:   0 10px 25px -3px rgb(0 0 0 / 0.15);
    --ag-radius:      10px;
    --ag-sidebar-w:   260px;
}

/* ── Reset Removed for Module Integration ──────────────────── */

/* ── Brand Bar ─────────────────────────────────────────── */
.ag-brand-bar {
    background: var(--ag-primary);
    color: #fff;
    text-align: center;
    padding: 11px 0;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,0,0,.12);
    z-index: 200;
    flex-shrink: 0;
}

/* ── Layout ─────────────────────────────────────────────── */
.ag-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.ag-sidebar {
    width: var(--ag-sidebar-w);
    background: var(--ag-sidebar-bg);
    border-right: 1px solid var(--ag-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: var(--ag-shadow-sm);
    overflow-y: auto;
    transition: width .25s ease;
}

.ag-sidebar-logo {
    padding: 20px 20px 12px;
    border-bottom: 1px solid var(--ag-border);
}

.ag-sidebar-logo img {
    height: 40px;
    width: auto;
    display: block;
}

.ag-sidebar-logo-text {
    font-size: .7rem;
    font-weight: 700;
    color: var(--ag-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 6px;
}

.ag-nav {
    flex: 1;
    padding: 12px 0;
}

.ag-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 8px;
    margin: 2px 8px;
    font-size: .875rem;
    font-weight: 600;
    color: var(--ag-muted);
    text-decoration: none;
    transition: background .15s, color .15s;
}

.ag-nav-item:hover {
    background: var(--ag-sidebar-hover);
    color: var(--ag-text);
}

.ag-nav-item.active {
    background: var(--ag-sidebar-active);
    color: var(--ag-blue);
    font-weight: 700;
}

.ag-nav-item .material-icons {
    font-size: 20px;
}

.ag-nav-sep {
    margin: 8px 24px;
    border: none;
    border-top: 1px solid var(--ag-border);
}

.ag-nav-back {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    margin: 8px 8px 0;
    cursor: pointer;
    border-radius: 8px;
    font-size: .8rem;
    font-weight: 700;
    color: var(--ag-primary);
    transition: background .15s;
    text-decoration: none;
}

.ag-nav-back:hover { background: #fff1f2; }

/* ── Main Content ─────────────────────────────────────── */
.ag-main {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* ── Page Header ─────────────────────────────────────── */
.ag-page-header {
    background: #fff;
    border-bottom: 1px solid var(--ag-border);
    padding: 20px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
    box-shadow: var(--ag-shadow-sm);
}

.ag-page-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ag-page-title h1 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--ag-text);
}

.ag-page-title span.material-icons {
    color: var(--ag-blue);
    font-size: 28px;
}

/* ── Stats Strip ─────────────────────────────────────── */
.ag-stats-strip {
    display: flex;
    gap: 16px;
    padding: 20px 32px;
    flex-wrap: wrap;
}

.ag-stat-card {
    background: #fff;
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius);
    padding: 16px 24px;
    min-width: 140px;
    flex: 1;
    box-shadow: var(--ag-shadow-sm);
    position: relative;
    overflow: hidden;
}

.ag-stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}
.ag-stat-card.total::before  { background: var(--ag-blue); }
.ag-stat-card.origin::before { background: #10b981; }
.ag-stat-card.dest::before   { background: #6366f1; }
.ag-stat-card.freight::before{ background: #f59e0b; }
.ag-stat-card.inactive::before{ background: #94a3b8; }

.ag-stat-label {
    font-size: .65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--ag-muted);
    margin-bottom: 6px;
}

.ag-stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--ag-text);
    line-height: 1;
}

/* ── Toolbar ─────────────────────────────────────────── */
.ag-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 32px 16px;
    flex-wrap: wrap;
}

.ag-search {
    flex: 1;
    min-width: 200px;
    padding: 9px 14px 9px 38px;
    border: 1px solid var(--ag-border);
    border-radius: 8px;
    font-size: .875rem;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E") no-repeat 12px center;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.ag-search:focus {
    border-color: var(--ag-blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.ag-filter-select {
    padding: 9px 14px;
    border: 1px solid var(--ag-border);
    border-radius: 8px;
    font-size: .875rem;
    background: #fff;
    cursor: pointer;
    outline: none;
}

.ag-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: .875rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: background .15s, transform .1s;
}

.ag-btn:active { transform: scale(.97); }

.ag-btn-primary {
    background: var(--ag-blue);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37,99,235,.3);
}

.ag-btn-primary:hover { background: var(--ag-blue-hover); }

.ag-btn-secondary {
    background: #f1f5f9;
    color: var(--ag-text);
}

.ag-btn-secondary:hover { background: #e2e8f0; }

.ag-btn-danger {
    background: #fee2e2;
    color: #dc2626;
}

.ag-btn-danger:hover { background: #fecaca; }

/* ── Table ─────────────────────────────────────────────── */
.ag-table-wrap {
    padding: 0 32px 32px;
    flex: 1;
}

.ag-table-card {
    background: #fff;
    border: 1px solid var(--ag-border);
    border-radius: var(--ag-radius);
    overflow: hidden;
    box-shadow: var(--ag-shadow-sm);
}

.ag-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.ag-table thead tr {
    background: #f8fafc;
    border-bottom: 2px solid var(--ag-border);
}

.ag-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: .65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--ag-muted);
    white-space: nowrap;
}

.ag-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background .1s;
}

.ag-table tbody tr:last-child { border-bottom: none; }

.ag-table tbody tr:hover { background: #f8fafc; }

.ag-table td {
    padding: 14px 16px;
    vertical-align: middle;
}

.ag-name-cell .name { font-weight: 700; color: var(--ag-text); }
.ag-name-cell .id   { font-size: .7rem; color: var(--ag-muted); margin-top: 2px; }

.ag-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: .65rem;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
}
.ag-badge-origin  { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.ag-badge-dest    { background: #ede9fe; color: #6d28d9; border: 1px solid #ddd6fe; }
.ag-badge-freight { background: #fef3c7; color: #d97706; border: 1px solid #fde68a; }
.ag-badge-other   { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }

.ag-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .65rem;
    font-weight: 800;
    text-transform: uppercase;
}
.ag-status-active   { background: #dcfce7; color: #15803d; }
.ag-status-inactive { background: #f1f5f9; color: #64748b; }
.ag-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.ag-dot-active   { background: #22c55e; animation: ag-pulse 2s infinite; }
.ag-dot-inactive { background: #94a3b8; }

@keyframes ag-pulse {
    0%,100%{ opacity: 1; } 50%{ opacity: .4; }
}

.ag-commission-val { font-weight: 700; color: #059669; }

/* ── Empty State ────────────────────────────────────────── */
.ag-empty {
    display: none;
    text-align: center;
    padding: 60px 20px;
    color: var(--ag-muted);
}
.ag-empty .material-icons { font-size: 56px; color: #cbd5e1; margin-bottom: 12px; display: block; }
.ag-empty h3 { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.ag-empty p  { font-size: .85rem; }

/* ── Modal Overlay ──────────────────────────────────────── */
.ag-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .65);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: ag-fade-in .2s ease;
}

.ag-overlay.open { display: flex; }

@keyframes ag-fade-in { from { opacity: 0; } to { opacity: 1; } }

.ag-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 640px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: var(--ag-shadow-lg);
    animation: ag-slide-up .25s ease;
}

@keyframes ag-slide-up {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.ag-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    border-bottom: 1px solid var(--ag-border);
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    border-radius: 16px 16px 0 0;
}

.ag-modal-header h2 {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ag-modal-close {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s;
}

.ag-modal-close:hover { background: rgba(255,255,255,.25); }

.ag-modal-body {
    padding: 28px;
}

/* Form Grid */
.ag-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.ag-form-grid .full { grid-column: 1 / -1; }

.ag-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ag-label {
    font-size: .7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--ag-muted);
}

.ag-label .req { color: #ef4444; }

.ag-input,
.ag-select,
.ag-textarea {
    padding: 10px 14px;
    border: 1.5px solid var(--ag-border);
    border-radius: 8px;
    font-size: .875rem;
    font-family: 'Inter', sans-serif;
    color: var(--ag-text);
    background: #fff;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
}

.ag-input:focus,
.ag-select:focus,
.ag-textarea:focus {
    border-color: var(--ag-blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.ag-textarea { resize: vertical; min-height: 80px; }

.ag-modal-footer {
    padding: 16px 28px;
    border-top: 1px solid var(--ag-border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #f8fafc;
    border-radius: 0 0 16px 16px;
}

/* ── Toast ──────────────────────────────────────────────── */
.ag-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1e293b;
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: .875rem;
    font-weight: 600;
    box-shadow: var(--ag-shadow-lg);
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: ag-slide-up .25s ease;
    max-width: 380px;
}

.ag-toast.success { border-left: 4px solid #22c55e; }
.ag-toast.error   { border-left: 4px solid #ef4444; }

/* ── Delete Confirm Modal ─────────────────────────────── */
.ag-confirm-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--ag-shadow-lg);
    padding: 32px;
    text-align: center;
    animation: ag-slide-up .25s ease;
}

.ag-confirm-modal .material-icons {
    font-size: 52px;
    color: #ef4444;
    margin-bottom: 12px;
}

.ag-confirm-modal h3 {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.ag-confirm-modal p {
    font-size: .875rem;
    color: var(--ag-muted);
    margin-bottom: 24px;
}

.ag-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .ag-sidebar       { display: none; }
    .ag-stats-strip   { gap: 10px; padding: 16px; }
    .ag-toolbar       { padding: 0 16px 12px; }
    .ag-table-wrap    { padding: 0 16px 24px; }
    .ag-page-header   { padding: 14px 16px; }
    .ag-form-grid     { grid-template-columns: 1fr; }
    .ag-form-grid .full { grid-column: 1; }
}
