/* ==============================================
   MAIZO VIEW - Styles
   Widok handlowy dopasowany do stylu CRM
   ============================================== */

/* ---- ANIMACJA WEJŚCIA ---- */
@keyframes cascadeIn {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

.maizo-page-header {
    opacity: 0;
    animation: cascadeIn 0.4s ease-out 0.1s forwards;
}

.maizo-content-card {
    opacity: 0;
    animation: cascadeIn 0.4s ease-out 0.2s forwards;
}

/* ---- KONTENER STRONY ---- */
.maizo-page-container {
    padding: 30px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height, 65px) - 60px);
    min-height: 600px;
    font-family: 'Montserrat', sans-serif;
    overflow: hidden;
}

.maizo-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.maizo-page-header h1 {
    font-size: 1.5rem;
    margin: 0;
    color: var(--text-primary, #2c3e50);
    display: flex;
    align-items: center;
    gap: 10px;
}

.maizo-page-header h1 i {
    color: var(--primary-green, #2d5a27);
}

/* ---- CONTENT-CARD WRAPPER ---- */
.maizo-content-card {
    background: var(--bg-card, #fff);
    border-radius: 12px;
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.08));
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

/* ---- SELEKTOR PRODUKTU (jak filter-panel-header) ---- */
.maizo-product-selector {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--primary-green, #2d5a27) 0%, var(--primary-green-light, #4a9142) 100%);
    flex-shrink: 0;
    position: relative;
}

.maizo-product-selector label {
    font-weight: 600;
    color: #fff;
    font-size: 0.9rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.maizo-product-selector label i {
    opacity: 0.85;
}

.maizo-product-selector select {
    padding: 8px 36px 8px 14px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    background: #fff;
    color: var(--text-primary, #2c3e50);
    min-width: 320px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232d5a27' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: all 0.2s ease;
}

.maizo-product-selector select:focus {
    outline: none;
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

/* ---- PRZYCISK MARŻA ---- */
.maizo-margin-btn {
    background: linear-gradient(135deg, #ea580c, #f97316);
    color: #fff;
    border: none;
    padding: 7px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(249,115,22,0.3);
    transition: all 0.2s;
    white-space: nowrap;
    position: relative;
}
.maizo-margin-btn:hover:not(.maizo-margin-btn-disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249,115,22,0.4);
}
.maizo-margin-btn-disabled {
    background: linear-gradient(135deg, #6b7280, #9ca3af);
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

/* Panel marży — style inline w HTML (identyczne z packages) */

/* ---- BODY (cała reszta pod selektorem) ---- */
.maizo-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

/* ---- WIERSZ Z UMOWAMI (LEWO + PRAWO) ---- */
.maizo-agreements-row {
    display: flex;
    gap: 0;
    flex: 1;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

/* ---- PANEL (umowy zakup / sprzedaż) ---- */
.maizo-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-card, #fff);
}

.maizo-panel + .maizo-panel {
    border-left: 1px solid var(--border-color, #e8ecef);
}

.maizo-panel-header {
    background: #f7fafc;
    color: var(--text-primary, #2c3e50);
    padding: 12px 20px;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 2px solid var(--border-color, #e8ecef);
}

.maizo-panel-header i {
    font-size: 0.9rem;
    color: var(--primary-green, #2d5a27);
}

.maizo-search-input {
    margin-left: auto;
    padding: 4px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Montserrat', sans-serif;
    width: 160px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
}
.maizo-search-input:focus {
    border-color: #2d5a27;
    box-shadow: 0 0 0 2px rgba(45,90,39,0.15);
}
.maizo-search-input::placeholder {
    color: #9ca3af;
    font-style: italic;
}

.maizo-count {
    background: var(--primary-green, #2d5a27);
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    margin-left: auto;
    font-weight: 700;
}

/* ---- TABELE (styl data-table z agreements-module) ---- */
.maizo-table-wrap {
    flex: 1;
    overflow: auto;
}

.maizo-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.maizo-table thead {
    background: #f7fafc;
}

.maizo-table thead th {
    padding: 7px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary, #2c3e50);
    border-bottom: 2px solid var(--border-color, #e8ecef);
    font-size: 0.73rem;
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f7fafc;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
}

/* Szerokości kolumn dla umów (6 kolumn) */
.maizo-table .col-nr { width: 16%; }
.maizo-table .col-name { width: 22%; }
.maizo-table .col-num { width: 14%; }
.maizo-table .col-progress { width: 18%; }
.maizo-table .col-date { width: 11%; }

.maizo-table tbody tr {
    cursor: pointer;
    transition: background 0.2s ease;
}

.maizo-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.maizo-table tbody tr:hover {
    background: #e8f4f8 !important;
}

.maizo-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-color, #e8ecef);
    color: var(--text-secondary, #5a6c7d);
    font-size: 0.78rem;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
}

/* ---- NIEBIESKIE PODŚWIETLENIE (powiązania) ---- */
.maizo-table tbody tr.maizo-selected {
    background: #2563eb !important;
    color: #fff !important;
}

.maizo-table tbody tr.maizo-selected td {
    color: #fff !important;
}

.maizo-table tbody tr.maizo-linked {
    background: #dbeafe !important;
    color: #1e40af !important;
}

.maizo-table tbody tr.maizo-linked td {
    color: #1e40af !important;
}

.maizo-table tbody tr.maizo-selected:hover,
.maizo-table tbody tr.maizo-linked:hover {
    filter: brightness(1.03);
}

/* ---- HINT ZIELONY (jasny - można połączyć) ---- */
.maizo-table tbody tr.maizo-hint-green {
    background: #dcfce7 !important;
    color: #166534 !important;
}

.maizo-table tbody tr.maizo-hint-green td {
    color: #166534 !important;
}

/* ---- HINT CZERWONY (jasny - brak tonażu) ---- */
.maizo-table tbody tr.maizo-hint-red {
    background: #fee2e2 !important;
    color: #991b1b !important;
}

.maizo-table tbody tr.maizo-hint-red td {
    color: #991b1b !important;
}

/* ---- PARA ZIELONA (można połączyć) ---- */
.maizo-table tbody tr.maizo-pair-green {
    background: #16a34a !important;
    color: #fff !important;
}

.maizo-table tbody tr.maizo-pair-green td {
    color: #fff !important;
}

.maizo-table tbody tr.maizo-pair-green:hover {
    filter: brightness(1.05);
}

/* ---- PARA CZERWONA (brak tonażu) ---- */
.maizo-table tbody tr.maizo-pair-red {
    background: #dc2626 !important;
    color: #fff !important;
}

.maizo-table tbody tr.maizo-pair-red td {
    color: #fff !important;
}

.maizo-table tbody tr.maizo-pair-red:hover {
    filter: brightness(1.05);
}

/* ---- SEKCJA ZLECEŃ TRANSPORTOWYCH (zakładki) ---- */
.maizo-to-section {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color, #e8ecef);
    background: var(--bg-card, #fff);
}

.maizo-to-section > .maizo-panel-header {
    background: #f0f4f8;
    border-bottom: 1px solid var(--border-color, #e8ecef);
}

.maizo-to-tabs {
    display: flex;
    gap: 0;
    padding: 0;
    overflow-x: auto;
    background: #f7fafc;
    min-height: 38px;
    align-items: stretch;
    border-bottom: 1px solid var(--border-color, #e8ecef);
}

.maizo-to-tab {
    padding: 9px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary, #6c7a89);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    font-family: inherit;
}

.maizo-to-tab:hover {
    background: #edf2f7;
    color: var(--text-primary, #2c3e50);
}

.maizo-to-tab.active {
    background: var(--bg-card, #fff);
    color: var(--primary-green, #2d5a27);
    border-bottom-color: var(--primary-green, #2d5a27);
    font-weight: 700;
}

.maizo-to-tab-own {
    color: #b45309 !important;
}

.maizo-to-tab-own.active {
    color: #92400e !important;
    border-bottom-color: #b45309 !important;
}

.maizo-to-placeholder {
    padding: 9px 20px;
    color: var(--text-light, #95a5a6);
    font-size: 0.82rem;
    font-style: italic;
    display: flex;
    align-items: center;
}

/* ---- SEKCJA TRANSPORTÓW ---- */
.maizo-transports-section {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color, #e8ecef);
    background: var(--bg-card, #fff);
    max-height: 240px;
    display: flex;
    flex-direction: column;
}

.maizo-transports-section > .maizo-panel-header {
    background: #eef2f7;
    border-bottom: 1px solid var(--border-color, #e8ecef);
}

.maizo-transports-section > .maizo-panel-header i {
    color: #3b82f6;
}

/* Tabela transportów - szerokości kolumn */
.maizo-table .col-t-date    { width: 15%; }
.maizo-table .col-t-waga    { width: 10%; }
.maizo-table .col-t-kierowca { width: 18%; }
.maizo-table .col-t-rejestr  { width: 18%; }
.maizo-table .col-t-awizo    { width: 14%; }

.maizo-transports-section .maizo-table {
    table-layout: fixed;
}

.maizo-transports-section .maizo-table tbody tr {
    cursor: default;
}

.maizo-transports-section .maizo-table tbody tr:hover {
    background: #eff6ff !important;
}

/* ---- PUSTA KOMÓRKA ---- */
.maizo-empty {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-light, #95a5a6);
    font-style: italic;
    font-size: 0.9rem;
}

/* ---- AWIZO IKONY ---- */
.maizo-awizo-yes {
    color: var(--status-green, #27ae60);
    font-size: 1rem;
}

.maizo-awizo-no {
    color: #dc2626;
    font-size: 1rem;
    opacity: 0.4;
}

/* ---- TYPY KOMÓREK ---- */
.cell-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.74rem;
    white-space: nowrap;
}

.cell-progress {
    text-align: center;
    padding: 4px 6px !important;
}

.mini-progress-bar {
    width: 100%;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 3px;
}

.mini-progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
    min-width: 0;
}

.mini-progress-text {
    font-size: 0.68rem;
    color: #6b7280;
    font-variant-numeric: tabular-nums;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    white-space: nowrap;
    line-height: 1;
}

/* Czytelny tekst pod paskiem przy ciemnych podświetleniach wiersza */
.maizo-table tbody tr.maizo-selected .mini-progress-text,
.maizo-table tbody tr.maizo-pair-green .mini-progress-text,
.maizo-table tbody tr.maizo-pair-red .mini-progress-text {
    color: #fff !important;
}

.cell-date {
    text-align: center;
    font-variant-numeric: tabular-nums;
    white-space: nowrap !important;
}

.cell-nr {
    font-weight: 600;
    color: var(--text-primary, #2c3e50);
}

.cell-name {
    max-width: 180px;
    white-space: normal;
    line-height: 1.3;
}

.cell-name .contractor-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-name .warehouse-city {
    display: block;
    font-size: 0.72rem;
    color: var(--text-light, #95a5a6);
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-awizo {
    text-align: center;
}

/* ---- SCROLLBAR (spójny z resztą CRM) ---- */
.maizo-table-wrap::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.maizo-table-wrap::-webkit-scrollbar-track {
    background: #f7fafc;
}

.maizo-table-wrap::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.maizo-table-wrap::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.maizo-to-tabs::-webkit-scrollbar {
    height: 4px;
}

.maizo-to-tabs::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

/* ---- AWIZO BUTTONS (identyczne jak w packages) ---- */
.btn-awizo-mini {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    white-space: nowrap;
}

.btn-awizo-mini:hover {
    opacity: 0.9;
}

.btn-awizo-mini.awizo-resend {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.btn-awizo-mini.awizo-change {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.btn-awizo-mini.awizo-change-resend {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.btn-awizo-mini.awizo-no-data {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: default;
}

/* Awizo modal sections */
.awizo-agreement-section {
    background: #f8fafc;
    border-radius: 8px;
    padding: 15px;
    border: 1px solid #e2e8f0;
}
.awizo-emails-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.awizo-email-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
}
.awizo-email-item:hover {
    border-color: #3b82f6;
}
.awizo-email-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}
.awizo-email-item label {
    flex: 1;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}
.awizo-email-name {
    font-weight: 500;
    color: #1e293b;
}
.awizo-email-address {
    font-size: 13px;
    color: #64748b;
}
.awizo-no-emails {
    color: #94a3b8;
    font-style: italic;
    padding: 10px;
}