/* ============================================
   PRINT STYLES — Clean reports without UI
   ============================================ */
@media print {
    .sidebar,
    .sidebar-footer,
    .no-print,
    .btn,
    .btn-primary,
    .btn-secondary,
    form,
    nav,
    .page-header p {
        display: none !important;
    }
    
    .main-content,
    .app-layout .main-content,
    .app-layout main,
    .app-layout .content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    
    .wrapper { display: block !important; }
    body { background: white !important; color: black !important; font-size: 12pt !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
    .table-container { overflow: visible !important; }
    table { font-size: 10pt !important; }
    h1 { font-size: 18pt !important; }
    h2 { font-size: 14pt !important; }
    h3 { font-size: 12pt !important; }
    a { color: black !important; text-decoration: none !important; }
    .page-header { border-bottom: 2px solid #333 !important; }
}

/* ============================================
   BUTTON SPACING — Consistent gaps
   ============================================ */
.btn + .btn,
.btn + a.btn,
a.btn + .btn,
a.btn + a.btn {
    margin-left: 0.5rem;
}

.btn-group,
.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

form[style*="display:inline"] + form[style*="display:inline"],
form[style*="display:inline"] + a.btn {
    margin-left: 0.5rem;
}

/* ============================================
   TABLE HEADER — search bar + action button
   ============================================ */
.table-header {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.table-header .search-form { width: 100%; }
.table-header > a.btn { margin-top: 0.25rem; }

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
}

.toast {
    padding: 1rem 1.25rem;
    border-radius: 10px;
    color: white;
    font-size: 0.9rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: toastIn 0.3s ease-out;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.toast::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(255,255,255,0.4);
    animation: toastTimer 5s linear forwards;
}

.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info { background: #2563eb; }

.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 0.25rem;
}
.toast-close:hover { color: white; }

@keyframes toastIn { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100px); } }
@keyframes toastTimer { from { width: 100%; } to { width: 0%; } }

/* ============================================
   ERROR / SUCCESS BOXES
   ============================================ */
.error-box {
    padding: 1rem 1.25rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #dc2626;
    border-radius: 8px;
    color: #991b1b;
    margin-bottom: 1.5rem;
}
.error-box ul { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.error-box ul li { margin-bottom: 0.25rem; }

.success-box {
    padding: 1rem 1.25rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-left: 4px solid #059669;
    border-radius: 8px;
    color: #166534;
    margin-bottom: 1.5rem;
}

/* ============================================
   SEARCH/FILTER BAR
   ============================================ */
.table-filter-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.table-filter-bar input[type="text"],
.table-filter-bar input[type="search"] {
    padding: 0.5rem 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    min-width: 250px;
}
.table-filter-bar input:focus { border-color: var(--primary-500); outline: none; }
.table-filter-bar select { padding: 0.5rem 0.75rem; border: 2px solid #e2e8f0; border-radius: 8px; font-size: 0.9rem; background: white; }

/* ============================================
   CONFIRM DIALOG
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s;
}

.modal-box {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    text-align: center;
}
.modal-box h3 { margin: 0 0 0.75rem; font-size: 1.1rem; color: #333; }
.modal-box p { margin: 0 0 1.5rem; color: #666; font-size: 0.9rem; }
.modal-box .modal-actions { display: flex; gap: 0.75rem; justify-content: center; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ============================================
   CENTER CREATE/EDIT FORMS ONLY
   Uses .form-card class — add to cards on
   create/edit pages only, NOT view pages.
   Also centers cards with inline max-width.
   ============================================ */
.main-content > .card[style*="max-width"],
.content-body > .card[style*="max-width"] {
    margin-left: auto;
    margin-right: auto;
}

/* ============================================
   KILL FORM AUTO-CARD STYLING ON VIEW PAGES
   Forms inside sections should stay inline,
   left-aligned, with no white card wrapper.
   ============================================ */
.main-content form,
.content-body form,
.main-content > div > form,
.content-body > div > form,
.main-content > form,
.content-body > form {
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    background: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* Restore card look ONLY for forms inside an explicit .card */
.card > form {
    background: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

/* Action rows — keep controls together and left-aligned */
.action-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-start;
}


/* ============================================
   DASHBOARD CARDS — three per row
   ============================================ */
.dashboard-cards {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 1.25rem !important;
    margin-top: 1.5rem;
    align-items: stretch;
}

.dashboard-cards .card {
    display: flex;
    flex-direction: column;
    max-width: none !important;
    margin: 0 !important;
}

.dashboard-cards .card h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

.dashboard-cards .card p {
    margin: 0 0 0.75rem;
    font-size: 0.875rem;
    color: #64748b;
}

.dashboard-cards .card .big-number {
    font-size: 2.25rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.1;
    margin: 0 0 0.35rem;
}

.dashboard-cards .card .btn {
    margin-top: auto;
    text-align: center;
    justify-content: center;
}

@media (max-width: 900px) {
    .dashboard-cards { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 600px) {
    .dashboard-cards { grid-template-columns: 1fr !important; }
}


/* ============================================
   MOBILE RESPONSIVE — staff pages
   ============================================ */
@media (max-width: 900px) {
    .wrapper .sidebar,
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 300;
    }
    .sidebar.open { transform: translateX(0); }

    .main-content {
        margin-left: 0 !important;
        padding: 1rem !important;
    }

    .dashboard-cards { grid-template-columns: repeat(2, 1fr) !important; }

    .table-container { overflow-x: auto; }
    .table { font-size: 0.82rem; }

    .page-header h1 { font-size: 1.35rem; }
}

@media (max-width: 600px) {
    .dashboard-cards { grid-template-columns: 1fr !important; }
    .table { font-size: 0.78rem; }
    .btn { padding: 0.5rem 0.9rem; font-size: 0.85rem; }
}


/* ============================================
   MOBILE TABLES — horizontal scroll instead of squash
   ============================================ */
/* ============================================
   KILL ALL HOVER ANIMATIONS GLOBALLY
   ============================================ */
.card, .card:hover,
.dashboard-card, .dashboard-card:hover,
.product-card, .product-card:hover,
.btn, .btn:hover,
.btn-primary:hover, .btn-secondary:hover,
.btn-edit:hover, .btn-stock:hover,
.btn-deactivate:hover, .btn-delete:hover,
.sidebar ul li a, .sidebar ul li a:hover, .sidebar ul li a.active,
.sidebar-footer a, .sidebar-footer a:hover,
.nav-item, .nav-item:hover,
.card a, .card a:hover,
.login-form button, .login-form button:hover {
    transform: none !important;
    transition: none !important;
}

.card:hover, .dashboard-card:hover, .product-card:hover {
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05) !important;
}

.product-card::after, .product-card:hover::after { display: none !important; }
.card a:hover, .login-form button:hover { filter: none !important; }

/* ============================================
   REMOVE ALL NON-BUTTON HOVER EFFECTS
   ============================================ */
a:not(.btn):hover { color: inherit; }
.product-card:hover .product-image img { transform: none !important; }
.thumbnail:hover { transform: none !important; }
.sidebar ul li a:hover, .sidebar ul li a.active { transform: none !important; }
.sidebar-footer a:hover { transform: none !important; }
.nav-item:hover { transform: none !important; }
.table tbody tr:hover { transform: none !important; }
.pagination a:hover { transform: none !important; }
.public-nav a::after { display: none !important; }
.search-bar input:hover, .search-bar select:hover { transform: none !important; }
.modal:hover { transform: none !important; }

/* ============================================
   FIX: Undo centering on search/filter forms
   ============================================ */
.table-header form,
.table-filter-bar form,
form[method="GET"],
form.search-form,
.search-bar form {
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    background: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}
/* ============================================================
   TABBED PANELS (client portfolio)
   ============================================================ */
.kmk-tabs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.kmk-tab {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.9rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    position: relative;
}
.kmk-tab:hover { background: #f8fafc; color: #1565C0; }
.kmk-tab.active {
    background: #1565C0;
    border-color: #1565C0;
    color: #fff;
}
.kmk-tab-count {
    display: inline-block;
    min-width: 20px;
    padding: 1px 7px;
    margin-left: 0.35rem;
    background: #e2e8f0;
    color: #475569;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
}
.kmk-tab.active .kmk-tab-count { background: rgba(255,255,255,0.25); color: #fff; }

.kmk-tab-panel { display: none; }
.kmk-tab-panel.active { display: block; }

@media (max-width: 1000px) { .kmk-tabs { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px)  { .kmk-tabs { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
                             .kmk-tab { padding: 0.7rem 0.5rem; font-size: 0.8rem; } }

/* lighter button text so Edit / Add Follow-up read clearly */
.kmk-btn-light,
.kmk-btn-light:hover { color: #ffffff !important; }

/* ============================================================
   RECENT DATA PANELS (dashboards)
   ============================================================ */
.kmk-recent-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-top: 1.75rem;
}
.kmk-recent-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1.25rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.kmk-recent-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
}
.kmk-recent-head h3 { margin: 0; font-size: 1rem; color: #1e293b; }
.kmk-recent-head a  { font-size: 0.8rem; color: #1565C0; text-decoration: none; font-weight: 600; }
.kmk-recent-empty   { color: #94a3b8; font-size: 0.875rem; margin: 0.5rem 0; }
.kmk-recent-panel .table { font-size: 0.82rem; }
.kmk-recent-panel .table th { padding: 0.5rem 0.6rem; font-size: 0.68rem; }
.kmk-recent-panel .table td { padding: 0.55rem 0.6rem; }

@media (max-width: 1100px) { .kmk-recent-grid { grid-template-columns: 1fr; } }

/* ============================================================
   ANALYTICS OVERVIEW
   ============================================================ */
.kmk-analytics { margin-top: 2rem; }
.kmk-analytics-head { margin-bottom: 1.25rem; }
.kmk-analytics-head h2 { margin: 0 0 0.25rem; font-size: 1.25rem; color: #1e293b; }
.kmk-analytics-head p  { margin: 0; color: #94a3b8; font-size: 0.85rem; }

.kmk-kpi-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.kmk-kpi {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.kmk-kpi-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #94a3b8;
}
.kmk-kpi-value { font-size: 1.15rem; font-weight: 700; color: #1e293b; }

.kmk-analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}
.kmk-chart-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1.25rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.kmk-chart-card h3 { margin: 0 0 1rem; font-size: 1rem; color: #1e293b; }

/* bar chart */
.kmk-bars {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    min-height: 200px;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}
.kmk-bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0.3rem;
    flex: 1;
    min-width: 42px;
}
.kmk-bar {
    width: 100%;
    max-width: 38px;
    background: linear-gradient(180deg, #2196f3, #1565C0);
    border-radius: 6px 6px 0 0;
}
.kmk-bar-value { font-size: 0.62rem; color: #64748b; font-weight: 600; white-space: nowrap; }
.kmk-bar-label { font-size: 0.68rem; color: #94a3b8; }

/* progress rows */
.kmk-progress-row { margin-bottom: 0.9rem; }
.kmk-progress-top {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #475569;
    margin-bottom: 0.3rem;
}
.kmk-progress-track {
    height: 9px;
    background: #f1f5f9;
    border-radius: 999px;
    overflow: hidden;
}
.kmk-progress-fill { height: 100%; border-radius: 999px; }

@media (max-width: 1200px) { .kmk-kpi-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1000px) { .kmk-analytics-grid { grid-template-columns: 1fr; } }
@media (max-width: 600px)  { .kmk-kpi-row { grid-template-columns: repeat(2, 1fr); } }

/* Keep dashboard grids within the viewport and hidden tab panels inaccessible. */
.kmk-recent-panel, .kmk-chart-card, .kmk-kpi, .kmk-tab { min-width:0; }
.kmk-kpi-value { overflow-wrap:anywhere; }
.kmk-tab-panel[hidden] { display:none !important; }

/* Client portfolio: larger controls and panels that use the available screen height. */
.kmk-client-tabs .kmk-tab {
    min-height: 4.5rem;
    padding: 1.1rem 0.9rem;
    font-size: 1rem;
    line-height: 1.4;
}
.kmk-client-panel > .card {
    min-height: max(22rem, calc(100vh - 19rem));
    min-height: max(22rem, calc(100dvh - 19rem));
}
.kmk-client-details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 2rem;
    margin-top: 1rem;
}
.kmk-client-details-grid p { overflow-wrap: anywhere; }
.kmk-client-messages {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid #e2e8f0;
}
@media (max-width: 600px) {
    .kmk-client-tabs .kmk-tab { min-height: 4rem; padding: 0.85rem 0.5rem; font-size: 0.9rem; }
    .kmk-client-panel > .card { min-height: 22rem; padding: 1.25rem; }
    .kmk-client-details-grid { grid-template-columns: 1fr; gap: 0.75rem; }
}
