/* ============================================================
   ZIMOZO ERP — Unified UI Components (cards, buttons)
   Use design tokens only. Load after theme-skins.css.
   ============================================================ */

/* ---- Cards (enterprise: flat, white, 12px radius) ---- */
.z-card {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transition: var(--z-transition);
}

.z-card:hover {
    border-color: #D1D5DB;
}

.z-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--z-space-4);
    padding: 16px 24px;
    border-bottom: 1px solid #E5E7EB;
    background: #FFFFFF;
    font-size: var(--z-text-sm);
}

.z-card__header--split {
    align-items: flex-start;
    flex-wrap: wrap;
}

/* Card title — 18px per enterprise spec */
.z-card__title {
    font-size: var(--z-text-lg);
    font-weight: var(--z-weight-semibold);
    color: var(--z-text);
    margin: 0;
}

.z-card__header-inner {
    display: flex;
    align-items: center;
    gap: var(--z-space-2);
}

.z-card__link {
    font-size: var(--z-text-xs);
    font-weight: var(--z-weight-medium);
    color: var(--z-primary);
    text-decoration: none;
}

.z-card__link:hover {
    text-decoration: underline;
}

.z-card__body {
    padding: 16px 24px;
}

/* Empty state */
.z-empty-state {
    padding: var(--z-space-8) var(--z-space-6);
    text-align: center;
    color: var(--z-text-secondary, #6B7280);
    font-size: var(--z-text-sm);
}
.z-empty-state__title {
    font-size: var(--z-text-base);
    font-weight: var(--z-weight-medium);
    color: var(--z-text-primary, #111827);
    margin: 0 0 var(--z-space-2);
}
.z-empty-state__text {
    margin: 0;
}

/* Table card (wrapper for tables with consistent filters/pagination) */
.z-table-card {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.z-table-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--z-space-4);
    padding: 16px 24px;
    border-bottom: 1px solid #E5E7EB;
    background: #FFFFFF;
}
.z-table-card__title {
    font-size: var(--z-text-lg);
    font-weight: var(--z-weight-semibold);
    color: var(--z-text-primary, #111827);
    margin: 0;
}
.z-table-card__body {
    padding: 0;
    overflow-x: auto;
}
.z-table-card .table thead th {
    background: #F9FAFB;
    padding: 12px 16px;
    font-size: var(--z-text-xs);
    font-weight: var(--z-weight-semibold);
    color: var(--z-text-secondary, #6B7280);
    border-bottom: 1px solid #E5E7EB;
}
.z-table-card .table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #E5E7EB;
    vertical-align: middle;
}
.z-table-card .table tbody tr:hover {
    background: #F3F4F6;
}

/* Stat / KPI card — enterprise spec */
.z-card-stat {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    min-height: 140px;
    transition: var(--z-transition);
}

.z-card-stat:hover {
    border-color: #D1D5DB;
}

.z-card-stat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--z-space-3);
    font-size: var(--z-text-sm);
    color: var(--z-text-muted);
}

.z-card-stat__title {
    font-weight: var(--z-weight-semibold);
    color: var(--z-text);
}

.z-card-stat__value {
    font-size: 1.375rem;
    font-weight: var(--z-weight-bold);
    color: var(--z-text);
    line-height: var(--z-line-height-tight);
    margin-top: var(--z-space-2);
}

.z-card-stat__meta {
    margin-top: auto;
    font-size: var(--z-text-xs);
    color: var(--z-text-light);
}

.z-card-stat__footer {
    margin-top: var(--z-space-2);
}

.z-card-stat__footer a {
    font-size: var(--z-text-xs);
    font-weight: var(--z-weight-medium);
    color: var(--z-primary);
    text-decoration: none;
}

.z-card-stat__footer a:hover {
    text-decoration: underline;
}

/* Inline stat row (icon + label + value) */
.z-card-stat--inline {
    flex-direction: row;
    align-items: center;
    gap: var(--z-space-4);
    min-height: 72px;
}

.z-card-stat__icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    background: var(--z-border-light, #F3F4F6);
    color: var(--z-text);
    flex-shrink: 0;
}

.z-card-stat__icon--primary { background: rgba(var(--z-primary-rgb), 0.15); color: var(--z-primary); }
.z-card-stat__icon--success { background: rgba(40, 167, 69, 0.15); color: var(--z-success); }
.z-card-stat__icon--warning { background: rgba(240, 173, 78, 0.2); color: var(--z-warning); }
.z-card-stat__icon--danger { background: rgba(226, 91, 91, 0.15); color: var(--z-danger); }
.z-card-stat__icon--info { background: rgba(23, 162, 184, 0.15); color: var(--z-info); }

/* ---- Buttons ---- */
.z-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--z-space-2);
    padding: 8px 16px;
    font-family: var(--z-font-family);
    font-size: var(--z-text-sm);
    font-weight: var(--z-weight-medium);
    line-height: var(--z-line-height-normal);
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--z-transition);
    text-decoration: none;
    white-space: nowrap;
    min-height: 36px;
}

.z-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.z-btn-primary {
    background: #111827;
    color: #FFFFFF;
    border: 1px solid #111827;
    border-radius: 8px;
    min-height: 36px;
}

.z-btn-primary:hover:not(:disabled) {
    background: #1F2937;
    color: #FFFFFF;
    border-color: #1F2937;
}

.z-btn-secondary {
    background: #FFFFFF;
    color: #374151;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    min-height: 36px;
}

.z-btn-secondary:hover:not(:disabled) {
    background: #F9FAFB;
    border-color: #9CA3AF;
    color: #111827;
}

.z-btn-ghost {
    background: transparent;
    color: var(--z-text);
}

.z-btn-ghost:hover:not(:disabled) {
    background: rgba(var(--z-primary-rgb), 0.08);
    color: var(--z-primary);
}

.z-btn-danger {
    background: var(--z-danger);
    color: #fff;
    border-color: var(--z-danger);
}

.z-btn-danger:hover:not(:disabled) {
    background: #c94a4a;
    color: #fff;
}

.z-btn-success {
    background: var(--z-success);
    color: #fff;
    border-color: var(--z-success);
}

.z-btn-success:hover:not(:disabled) {
    background: #218838;
    color: #fff;
}

.z-btn-sm {
    padding: var(--z-space-1) var(--z-space-3);
    font-size: var(--z-text-xs);
}

.z-btn-lg {
    padding: var(--z-space-3) var(--z-space-6);
    font-size: var(--z-text-base);
}

/* Semantic text colors (dashboard change indicators, status) */
.z-text-success { color: var(--z-success) !important; }
.z-text-danger { color: var(--z-danger) !important; }
.z-text-warning { color: var(--z-warning) !important; }

/* Minimum touch target for mobile */
@media (max-width: 1024px) {
    .z-btn {
        min-height: 44px;
        min-width: 44px;
    }
    .z-btn-sm {
        min-height: 36px;
        min-width: 36px;
    }
}

/* Compatibility: Bootstrap .btn.btn-primary — enterprise (#111827) */
.btn.btn-primary,
button.btn-primary {
    background: #111827 !important;
    color: #FFFFFF !important;
    border-color: #111827 !important;
    border-radius: 8px !important;
    min-height: 36px !important;
}

.btn.btn-primary:hover:not(:disabled),
button.btn-primary:hover:not(:disabled) {
    background: #1F2937 !important;
    color: #FFFFFF !important;
    border-color: #1F2937 !important;
}

/* Secondary / default button — white + border */
.btn.btn-default,
button.btn-default {
    background: #FFFFFF !important;
    color: #374151 !important;
    border: 1px solid #D1D5DB !important;
    border-radius: 8px !important;
}
.btn.btn-default:hover:not(:disabled),
button.btn-default:hover:not(:disabled) {
    background: #F9FAFB !important;
    border-color: #9CA3AF !important;
    color: #111827 !important;
}

.z-card__header--split {
    align-items: flex-start;
    flex-wrap: wrap;
}

/* ---- Page content area (soft gray background, spacing) ---- */
.z-content {
    background: var(--z-bg-page, #F8FAFC);
    min-height: 100%;
    padding: 24px 32px;
}
@media (max-width: 768px) {
    .z-content { padding: 16px; }
}

/* ---- Content layout (section.content, content-header) — enterprise ---- */
section.content-header {
    margin-bottom: var(--z-space-6, 24px);
    padding: 0;
}
section.content-header h1 {
    font-size: var(--z-text-xl, 1.25rem);
    font-weight: var(--z-weight-bold, 700);
    color: var(--z-text-primary, #111827);
    margin: 0 0 var(--z-space-1, 4px) 0;
    line-height: var(--z-line-height-tight);
}
section.content-header h1 .text-muted,
section.content-header h1 small {
    font-size: var(--z-text-sm);
    font-weight: var(--z-weight-normal);
    color: var(--z-text-secondary, #6B7280);
    margin-left: 8px;
}
section.content {
    padding: 0;
    background: transparent;
}

/* ---- Modals (enterprise: no gradients, clean header) ---- */
.modal-content {
    border-radius: var(--z-radius-card, 12px);
    border: 1px solid var(--z-border);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}
.modal-header {
    background: #FFFFFF !important;
    border-bottom: 1px solid var(--z-border);
    padding: 16px 24px;
    border-radius: 12px 12px 0 0;
}
.modal-header .modal-title {
    font-size: var(--z-text-lg);
    font-weight: var(--z-weight-semibold);
    color: var(--z-text-primary);
}
.modal-header .close {
    color: var(--z-text-secondary);
    opacity: 0.8;
}
.modal-body {
    padding: 24px;
    background: #FFFFFF;
}
.modal-footer {
    border-top: 1px solid var(--z-border);
    padding: 16px 24px;
    background: #F9FAFB;
    border-radius: 0 0 12px 12px;
}

/* ---- DataTables inside content (consistent with table card) ---- */
.z-content .dataTables_wrapper,
section.content .dataTables_wrapper {
    font-size: var(--z-text-sm);
}
.z-content .dataTables_wrapper .table,
section.content .dataTables_wrapper .table {
    margin-bottom: 0;
}
.z-content .dataTables_wrapper thead th,
section.content .dataTables_wrapper thead th {
    background: var(--z-bg-table-head) !important;
    color: var(--z-text-secondary) !important;
    font-weight: var(--z-weight-semibold);
    padding: 12px 16px;
    border-bottom: 1px solid var(--z-border);
}
.z-content .dataTables_wrapper tbody td,
section.content .dataTables_wrapper tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--z-border);
    color: var(--z-text-primary);
}
.z-content .dataTables_wrapper tbody tr:hover,
section.content .dataTables_wrapper tbody tr:hover {
    background: var(--z-bg-row-hover) !important;
}
.z-content .dataTables_wrapper .dataTables_paginate,
section.content .dataTables_wrapper .dataTables_paginate {
    padding: 16px 0 0;
}
.z-content .dataTables_wrapper .dataTables_filter input,
section.content .dataTables_wrapper .dataTables_filter input {
    border-radius: var(--z-radius-btn);
    border: 1px solid var(--z-border-input);
    padding: 8px 12px;
    font-size: var(--z-text-sm);
}
.z-content .dataTables_wrapper .dataTables_length select,
section.content .dataTables_wrapper .dataTables_length select {
    border-radius: var(--z-radius-btn);
    border: 1px solid var(--z-border-input);
    padding: 6px 10px;
    font-size: var(--z-text-sm);
}

/* ---- Card title (18px) for card headers ---- */
.z-card__title--lg {
    font-size: var(--z-text-lg);
    font-weight: var(--z-weight-semibold);
    color: var(--z-text-primary, #111827);
}

/* ---- ERP table card + table ---- */
.z-table-wrap {
    background: #FFFFFF;
    border: 1px solid var(--z-border);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}
.z-table-wrap .z-table,
table.z-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--z-text-sm);
}
.z-table thead th,
table.z-table thead th {
    background: var(--z-bg-table-head, #F9FAFB);
    color: var(--z-text-secondary, #6B7280);
    font-weight: var(--z-weight-semibold);
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--z-border);
}
.z-table tbody td,
table.z-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--z-border);
    color: var(--z-text-primary, #111827);
}
.z-table tbody tr:hover,
table.z-table tbody tr:hover {
    background: var(--z-bg-row-hover, #F3F4F6);
}
.z-table tbody tr:last-child td,
table.z-table tbody tr:last-child td {
    border-bottom: none;
}

/* ---- Tabs (minimal) ---- */
.z-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--z-border);
    margin-bottom: 0;
}
.z-tabs__item {
    padding: 12px 16px;
    font-size: var(--z-text-sm);
    font-weight: var(--z-weight-medium);
    color: var(--z-text-secondary, #6B7280);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.z-tabs__item:hover { color: var(--z-text-primary); }
.z-tabs__item.active {
    color: var(--z-text-primary);
    border-bottom-color: var(--z-text-primary);
}

/* ---- Forms ---- */
.z-form-group { margin-bottom: var(--z-space-4); }
.z-label {
    display: block;
    font-size: var(--z-text-sm);
    font-weight: var(--z-weight-medium);
    color: var(--z-text-primary);
    margin-bottom: var(--z-space-2);
}
.z-input,
.z-form-group .form-control {
    width: 100%;
    padding: 8px 12px;
    font-size: var(--z-text-sm);
    border: 1px solid var(--z-border-input);
    border-radius: 8px;
    background: #FFFFFF;
    color: var(--z-text-primary);
    transition: var(--z-transition);
}
.z-input:focus,
.z-form-group .form-control:focus {
    outline: none;
    border-color: var(--z-primary, #111827);
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);
}
.z-btn:focus-visible,
.z-btn-primary:focus-visible,
.z-btn-secondary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.2);
}
.z-form-hint {
    font-size: var(--z-text-xs);
    color: var(--z-text-secondary);
    margin-top: var(--z-space-1);
}

/* ---- Badges ---- */
.z-badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: var(--z-text-xs);
    font-weight: var(--z-weight-medium);
    border-radius: 6px;
}
.z-badge--success { background: rgba(40, 167, 69, 0.12); color: #166534; }
.z-badge--warning { background: rgba(245, 158, 11, 0.12); color: #92400E; }
.z-badge--danger { background: rgba(239, 68, 68, 0.12); color: #991B1B; }
.z-badge--info { background: rgba(59, 130, 246, 0.12); color: #1E40AF; }

/* ---- Empty state ---- */
.z-empty-state {
    text-align: center;
    padding: 32px 24px;
    color: var(--z-text-secondary, #6B7280);
    font-size: var(--z-text-sm);
}
.z-empty-state__icon {
    font-size: 2.5rem;
    color: var(--z-border);
    margin-bottom: 16px;
}
.z-empty-state__title {
    font-weight: var(--z-weight-medium);
    color: var(--z-text-primary);
    margin-bottom: 8px;
}
.z-empty-state__action { margin-top: 16px; }

/* ---- Page title ---- */
.z-page-title {
    font-size: var(--z-text-xl);
    font-weight: var(--z-weight-bold);
    color: var(--z-text-primary);
    margin: 0 0 24px 0;
}
.z-page-subtitle {
    font-size: var(--z-text-sm);
    color: var(--z-text-secondary);
    margin: -16px 0 24px 0;
}

/* ---- Page header (title + actions) ---- */
.z-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--z-space-4);
    margin-bottom: var(--z-space-6);
}
.z-page-header__title {
    font-size: var(--z-text-lg);
    font-weight: var(--z-weight-semibold);
    color: var(--z-text-primary);
    margin: 0;
}
.z-page-header__actions {
    display: flex;
    align-items: center;
    gap: var(--z-space-2);
}

/* ---- Filter bar (forms above tables) ---- */
.z-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--z-space-3);
    margin-bottom: var(--z-space-4);
}
.z-filter-bar .form-control,
.z-filter-bar .z-input {
    min-width: 140px;
    border-radius: var(--z-radius-btn);
    border: 1px solid var(--z-border-input);
    padding: 8px 12px;
    font-size: var(--z-text-sm);
}

/* ---- Table card (card wrapper with optional filter + table) ---- */
.z-table-card {
    background: #FFFFFF;
    border: 1px solid var(--z-border);
    border-radius: var(--z-radius-card);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}
.z-table-card__toolbar {
    padding: var(--z-space-4) var(--z-space-6);
    border-bottom: 1px solid var(--z-border);
    background: #FFFFFF;
}
.z-table-card__body {
    overflow-x: auto;
}
/* Bootstrap table inside z-table-card gets enterprise styling */
.z-table-card .table,
.z-table-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--z-text-sm);
}
.z-table-card .table thead th,
.z-table-card table thead th {
    background: var(--z-bg-table-head);
    color: var(--z-text-secondary);
    font-weight: var(--z-weight-semibold);
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--z-border);
}
.z-table-card .table tbody td,
.z-table-card table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--z-border);
    color: var(--z-text-primary);
}
.z-table-card .table tbody tr:hover,
.z-table-card table tbody tr:hover {
    background: var(--z-bg-row-hover);
}
.z-table-card .table tbody tr:last-child td,
.z-table-card table tbody tr:last-child td {
    border-bottom: none;
}

/* ---- Pagination wrapper ---- */
.z-pagination-wrap {
    padding: var(--z-space-4) var(--z-space-6);
    border-top: 1px solid var(--z-border);
    background: #FFFFFF;
}

/* ---- Alerts (flash messages) ---- */
.alert.alert-success {
    background: rgba(40, 167, 69, 0.08);
    border: 1px solid rgba(40, 167, 69, 0.25);
    border-radius: var(--z-radius-btn);
    color: #166534;
}
.alert.alert-danger {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--z-radius-btn);
    color: #991B1B;
}
.alert.alert-info {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: var(--z-radius-btn);
    color: #1E40AF;
}

/* Legacy .box compatibility — align with z-card look where still used */
.box, .box-primary, .box-solid, .box-default, .box-info, .box-warning {
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}
.box-header.with-border,
.box-header {
    padding: 16px 24px;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.box-title {
    font-size: var(--z-text-lg);
    font-weight: var(--z-weight-semibold);
    color: var(--z-text, #374151);
    margin: 0;
}
.box-body, .box-body.p-10 {
    padding: 16px 24px;
}
