/* ========================================
   GENERAL GRIDS — Unified grid for Products,
   Companies, Silos, Transporters, Auto Reports
   Matches tickets-admin.css pattern
   ======================================== */

/* ---- Container — fills remaining viewport space ---- */
.gg-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    min-height: 0;
}

/* .ml-main is position:fixed top:60px bottom:0 with overflow:auto.
   We need gen-wrapper to fill it exactly and prevent .ml-main from
   scrolling — the grid handles its own scrolling internally. */
.gen-wrapper {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    overflow: hidden;
}

.gen-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* ---- Header bar — dark chrome ---- */
.gg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--chrome-bg);
    padding: 14px 24px;
    position: relative;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 12px;
}

.gg-header::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-primary), transparent);
}

.gg-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.gg-header-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--accent-10);
    border: 1px solid var(--accent-20);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    flex-shrink: 0;
}

.gg-header-icon [data-lucide] { width: 16px; height: 16px; }

.gg-header-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--chrome-text);
    letter-spacing: 0.01em;
}

.gg-header-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--chrome-text-dim);
    margin-left: 4px;
}

.gg-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- Buttons ---- */
.gg-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    font-family: var(--font-sans);
}

.gg-btn [data-lucide] { width: 13px; height: 13px; }

.gg-btn-amber {
    background: var(--accent-primary);
    color: var(--on-accent);
}
.gg-btn-amber:hover { background: var(--accent-secondary); }

.gg-btn-ghost {
    background: var(--chrome-hover);
    color: var(--chrome-text);
    border: 1px solid var(--chrome-border);
}
.gg-btn-ghost:hover {
    background: var(--chrome-active);
    color: var(--chrome-text);
}

.gg-btn-ghost.gg-btn-active {
    background: var(--accent-15);
    color: var(--accent-primary);
    border-color: var(--accent-30);
}

.gg-btn-archive-count {
    font-size: 10px;
    font-weight: 700;
    background: var(--chrome-active);
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 2px;
}

.gg-btn-ghost.gg-btn-active .gg-btn-archive-count {
    background: var(--accent-20);
}

/* ---- Search ---- */
.gg-search {
    position: relative;
    display: flex;
    align-items: center;
}

.gg-search [data-lucide] {
    position: absolute;
    left: 10px;
    width: 14px;
    height: 14px;
    color: var(--chrome-text-dim);
    pointer-events: none;
}

.gg-search-input {
    width: 240px;
    height: 32px;
    padding: 0 32px 0 32px;
    background: var(--chrome-hover);
    border: 1px solid var(--chrome-border);
    border-radius: 5px;
    color: var(--chrome-text);
    font-size: 12px;
    font-family: var(--font-sans);
    transition: all 0.15s ease;
}

.gg-search-input::placeholder { color: var(--chrome-text-dim); }
.gg-search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: var(--chrome-hover);
}

.gg-search-clear {
    position: absolute;
    right: 6px;
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--chrome-text-dim);
    cursor: pointer;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gg-search-clear:hover { color: var(--chrome-text); background: var(--chrome-active); }
.gg-search-clear [data-lucide] { width: 12px; height: 12px; }

/* ---- Grid table ---- */
.gg-grid {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
}

.gg-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
}

/* ---- Table header ---- */
.gg-table thead {
    position: sticky;
    top: 0;
    z-index: 4;
}

.gg-th {
    background: var(--chrome-bg);
    color: var(--chrome-text-muted);
    font-size: var(--grid-header-font-size);
    font-weight: 700;
    padding: var(--grid-header-padding-y) var(--grid-header-padding-x);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--chrome-border);
    border-right: 1px solid var(--chrome-border);
    cursor: pointer;
    user-select: none;
    transition: background 0.1s;
    font-family: var(--font-sans);
    height: var(--grid-header-height);
    line-height: var(--grid-line-height);
    box-sizing: border-box;
}

.gg-th:last-child { border-right: none; }
.gg-th:hover { background: var(--chrome-hover); }

.gg-th-sort {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.gg-th [data-lucide] {
    width: 10px;
    height: 10px;
    color: var(--accent-primary);
    flex-shrink: 0;
}

.gg-th-nosort {
    cursor: default;
}
.gg-th-nosort:hover { background: var(--chrome-bg); }

/* ---- Table body ---- */
.gg-td {
    padding: var(--grid-row-padding-y) var(--grid-row-padding-x);
    font-size: var(--grid-font-size);
    font-weight: 400;
    line-height: var(--grid-line-height);
    color: var(--text-body);
    border-bottom: 1px solid var(--border-primary);
    border-right: 1px solid rgba(0, 0, 0, 0.03);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: var(--grid-row-height);
    vertical-align: middle;
    font-family: var(--font-sans);
    box-sizing: border-box;
}

.gg-td:last-child { border-right: none; }

/* Dark mode body */
[data-theme="dark"] .gg-td { border-right-color: rgba(255,255,255,0.03); }

/* Alternating rows */
.gg-row { transition: background 0.1s; cursor: pointer; user-select: none; }
.gg-row:hover { background: var(--surface-warm, rgba(0, 0, 0, 0.02)); }
.gg-row-alt { background: var(--bg-secondary, rgba(0, 0, 0, 0.015)); }
.gg-row-alt:hover { background: var(--surface-warm, rgba(0, 0, 0, 0.04)); }

/* Row selection — amber highlight */
.gg-row-selected { background: var(--accent-10) !important; }
.gg-row-selected:hover { background: var(--accent-15) !important; }
.gg-row-selected td:first-child { box-shadow: inset 3px 0 0 0 var(--accent-primary); }

[data-theme="dark"] .gg-row:hover { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .gg-row-alt { background: rgba(255,255,255,0.015); }
[data-theme="dark"] .gg-row-selected { background: var(--accent-15) !important; }
[data-theme="dark"] .gg-row-selected:hover { background: var(--accent-20) !important; }

/* ---- Code link (clickable first column) ---- */
.gg-code-link {
    font-family: var(--font-numeric, var(--font-mono));
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 12px;
    color: var(--accent-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: var(--accent-30);
    cursor: pointer;
    transition: all 0.1s;
    letter-spacing: 0.02em;
}

.gg-code-link:hover {
    color: var(--accent-primary);
    text-decoration-color: var(--accent-primary);
}

/* ---- Cell variations ---- */
.gg-td-desc {
    font-weight: 400;
    color: var(--text-secondary);
}

.gg-td-center {
    text-align: center;
}

.gg-td-num {
    font-family: var(--font-numeric, var(--font-mono));
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    text-align: center;
}

.gg-td-muted {
    color: var(--text-muted);
    font-size: 11px;
}

.gg-td-date {
    font-family: var(--font-numeric, var(--font-mono));
    font-variant-numeric: tabular-nums;
    font-size: 11px;
    color: var(--text-secondary);
}

/* ---- Badges ---- */
.gg-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}

.gg-badge [data-lucide] { width: 10px; height: 10px; }

.gg-badge-success {
    background: var(--success-light);
    color: var(--success);
}

.gg-badge-info {
    background: var(--info-light);
    color: var(--info);
}

.gg-badge-warning {
    background: var(--accent-10);
    color: var(--accent-secondary);
}

.gg-badge-danger {
    background: var(--error-light);
    color: var(--error);
}

.gg-badge-secondary {
    background: var(--border-primary);
    color: var(--text-muted);
}

.gg-badge-active {
    background: var(--success-light);
    color: var(--success);
}

.gg-badge-inactive {
    background: var(--error-light);
    color: var(--error);
}

/* ---- Pagination — always at screen bottom ---- */
.gg-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--chrome-bg);
    border-top: 1px solid var(--chrome-border);
    flex-shrink: 0;
    margin-top: auto;
}

.gg-page-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--chrome-border);
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chrome-text-muted);
    transition: all 0.15s;
}

.gg-page-btn [data-lucide] { width: 14px; height: 14px; }

.gg-page-btn:hover:not(:disabled) {
    background: var(--accent-primary);
    color: var(--on-accent);
    border-color: var(--accent-primary);
}

.gg-page-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.gg-page-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    color: var(--chrome-text-muted);
    font-weight: 500;
}

.gg-page-info strong {
    font-weight: 700;
    color: var(--chrome-text);
}

.gg-page-divider { color: var(--chrome-text-dim); }

/* ---- Loading ---- */
.gg-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 16px;
    flex: 1;
}

.gg-loader-ring {
    width: 32px;
    height: 32px;
    border: 2px solid var(--accent-15);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: gg-spin 0.8s linear infinite;
}

@keyframes gg-spin { to { transform: rotate(360deg); } }

.gg-loading p {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    margin: 0;
}

/* ---- No Results ---- */
.gg-no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 12px;
}

.gg-no-results [data-lucide] {
    width: 40px;
    height: 40px;
    color: var(--border-secondary);
}

.gg-no-results p {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0;
}

/* ---- Scrollbar ---- */
.gg-grid::-webkit-scrollbar { width: 4px; height: 10px; }
.gg-grid::-webkit-scrollbar-track { background: var(--bg-primary); }
.gg-grid::-webkit-scrollbar-thumb { background: var(--border-secondary); border-radius: 4px; }
.gg-grid::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Status dot ---- */
.gg-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.gg-status-active { background: var(--success); box-shadow: 0 0 4px rgba(34,197,94,0.4); }
.gg-status-inactive { background: var(--error); box-shadow: 0 0 4px rgba(239,68,68,0.3); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .gg-header { padding: 10px 14px; }
    .gg-header-title { font-size: 13px; }
    .gg-search-input { width: 160px; }
    .gg-th { font-size: 9px; padding: 6px 8px; }
    .gg-td { font-size: 11px; padding: 5px 8px; }
    .gg-btn { padding: 6px 10px; font-size: 10px; }
}
