/* Smart Table Manager – Frontend Styles */

.stm-wrapper {
    margin: 1.5em 0;
    font-family: inherit;
}

.stm-table-title {
    font-size: 1.15em;
    font-weight: 700;
    margin-bottom: 0.6em;
    color: #1a3a5c;
}

.stm-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Tabel de bază */
table.stm-table {
    width: 100% !important;
    border-collapse: collapse;
    font-size: 0.93em;
    background: #fff;
    border: 1px solid #dde3ec;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

table.stm-table thead th {
    background: #1a3a5c;
    color: #fff;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2px solid #0f2540;
    cursor: pointer;
    user-select: none;
    transition: background .15s;
}

table.stm-table thead th:hover {
    background: #244e7a;
}

table.stm-table thead th.sorting_asc::after  { content: ' ▲'; font-size: .75em; }
table.stm-table thead th.sorting_desc::after { content: ' ▼'; font-size: .75em; }

table.stm-table tbody tr:nth-child(even) { background: #f5f8fc; }
table.stm-table tbody tr:hover           { background: #e8f0fb; transition: background .1s; }
table.stm-table tbody td                 { padding: 9px 14px; border-bottom: 1px solid #e8ecf2; color: #333; }
table.stm-table tbody tr:last-child td   { border-bottom: none; }

table.stm-table caption {
    caption-side: bottom;
    font-size: .83em;
    color: #666;
    padding: 6px 0 0;
    text-align: left;
}

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #ccd3de;
    border-radius: 4px;
    padding: 5px 10px;
    margin-left: 6px;
    font-size: .9em;
}

.dataTables_wrapper .dataTables_length select {
    border: 1px solid #ccd3de;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: .9em;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 4px !important;
    padding: 4px 10px !important;
    font-size: .88em;
    cursor: pointer;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: #1a3a5c !important;
    color: #fff !important;
    border-color: #1a3a5c !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #e8f0fb !important;
    color: #1a3a5c !important;
    border-color: #ccd3de !important;
}

/* Butoane export */
.dt-buttons {
    margin-bottom: 10px;
}

.dt-buttons .dt-button {
    background: #1a3a5c !important;
    color: #fff !important;
    border: none !important;
    border-radius: 4px !important;
    padding: 5px 12px !important;
    font-size: .85em !important;
    cursor: pointer !important;
    margin-right: 4px !important;
    transition: background .15s !important;
}

.dt-buttons .dt-button:hover {
    background: #244e7a !important;
}

/* Erori */
.stm-error {
    color: #c0392b;
    border: 1px solid #e74c3c;
    background: #fdf5f5;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: .9em;
}

/* Responsive */
@media (max-width: 600px) {
    table.stm-table thead th,
    table.stm-table tbody td { padding: 7px 8px; font-size: .85em; }
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length { display: block; margin-bottom: 8px; }
}

/* ── Freeze header ── */
.stm-freeze { overflow-y: auto; max-height: 450px; }
.stm-freeze .stm-table thead { position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 4px rgba(0,0,0,.1); }

/* ── Filtre dropdown per coloană ── */
.stm-col-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    background: #f5f8fc;
    border: 1px solid #dde3ec;
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 12px;
}
.stm-filter-item { display: flex; flex-direction: column; gap: 4px; }
.stm-filter-item label { font-size: 11.5px; font-weight: 600; color: #555; }
.stm-filter-item select {
    border: 1px solid #ccd3de;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
}
.stm-filter-clear {
    background: #fff;
    border: 1px solid #e74c3c;
    color: #e74c3c;
    border-radius: 4px;
    padding: 5px 10px;
    font-size: 12.5px;
    cursor: pointer;
    align-self: flex-end;
    font-family: inherit;
    transition: all .15s;
}
.stm-filter-clear:hover { background: #e74c3c; color: #fff; }

/* ── Grafic ── */
.stm-chart-container {
    position: relative;
    margin-bottom: 14px;
    max-height: 320px;
    background: #fff;
    border: 1px solid #dde3ec;
    border-radius: 6px;
    padding: 14px;
}
.stm-btn-toggle-chart {
    background: transparent;
    border: 1px solid #ccd3de;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12.5px;
    cursor: pointer;
    margin-bottom: 10px;
    font-family: inherit;
    color: #555;
    transition: all .15s;
}
.stm-btn-toggle-chart:hover { background: #e8f0fb; color: #1a3a5c; border-color: #1a3a5c; }

@media (max-width: 600px) {
    .stm-col-filters { flex-direction: column; }
    .stm-chart-container { max-height: 220px; }
}

/* ── Freeze prima coloană ── */
.stm-freeze-col tbody td:first-child,
.stm-freeze-col thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 5;
    background: inherit;
    box-shadow: 2px 0 4px rgba(0,0,0,.08);
}
.stm-freeze-col thead th:first-child { z-index: 11; background: var(--stm-header-bg, #1a3a5c); }

/* ── Mod card pe mobil ── */
@media (max-width: 600px) {
    table.stm-table.stm-card-mobile,
    table.stm-table.stm-card-mobile thead,
    table.stm-table.stm-card-mobile tbody,
    table.stm-table.stm-card-mobile th,
    table.stm-table.stm-card-mobile td,
    table.stm-table.stm-card-mobile tr { display: block !important; }

    table.stm-table.stm-card-mobile thead tr { display: none !important; }

    table.stm-table.stm-card-mobile tbody tr {
        margin-bottom: 14px;
        border: 1px solid #dde3ec;
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 1px 4px rgba(0,0,0,.07);
        background: #fff;
    }

    table.stm-table.stm-card-mobile tbody td {
        display: flex !important;
        justify-content: space-between;
        align-items: flex-start;
        padding: 9px 14px;
        border-bottom: 1px solid #f0f0f0;
        font-size: 13px;
    }

    table.stm-table.stm-card-mobile tbody td:last-child { border-bottom: none; }

    table.stm-table.stm-card-mobile tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 11.5px;
        color: #1a3a5c;
        text-transform: uppercase;
        letter-spacing: .04em;
        margin-right: 12px;
        flex-shrink: 0;
        min-width: 100px;
    }
}

/* ── Editare inline frontend ── */
.stm-inline-edit {
    outline: 2px solid #f0a500;
    outline-offset: -2px;
    background: #fff9e8 !important;
    cursor: text;
    min-width: 60px;
    position: relative;
}
.stm-inline-edit::after {
    content: '✏️';
    position: absolute;
    top: 2px; right: 4px;
    font-size: 10px;
    opacity: .5;
}
.stm-inline-edit:focus { outline-color: #1a3a5c; background: #fff !important; }

.stm-inline-input {
    border: none;
    background: transparent;
    width: 100%;
    font: inherit;
    outline: none;
    padding: 0;
}

.stm-inline-toolbar {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: #fff;
    border: 1px solid #dde3ec;
    border-radius: 4px;
    padding: 4px;
    display: flex;
    gap: 4px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.stm-inline-toolbar button {
    border: none; border-radius: 3px; padding: 3px 8px; font-size: 12px; cursor: pointer; font-family: inherit;
}
.stm-inline-save-btn { background: #2e7d32; color: #fff; }
.stm-inline-cancel-btn { background: #f5f5f5; color: #333; }

.stm-inline-error {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    background: #d32f2f;
    color: #fff;
    font-size: 11.5px;
    padding: 3px 8px;
    border-radius: 3px;
    z-index: 101;
    white-space: nowrap;
}

.stm-saving { opacity: .6; pointer-events: none; }
