/* ZYZ Retail & Wholesale ERP - base styles */
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", "Tahoma", "Cairo", "Arial", sans-serif;
    background: #f4f6f9;
    color: #222;
    direction: rtl;
}

/* Print rules — force portrait A4 and hide screen chrome */
@media print {
    @page { size: A4 portrait; margin: 12mm; }
    html, body { background: #fff !important; }
    .topbar, .mainnav, .footer, .no-print, .btn, button, form.filters,
    nav, header.topbar, .dropdown { display: none !important; }
    .container { max-width: 100% !important; margin: 0 !important; padding: 0 !important; }
    main.container { margin: 0 !important; padding: 0 !important; }
    a { color: #000 !important; text-decoration: none !important; }
    table { width: 100% !important; border-collapse: collapse !important; page-break-inside: auto; }
    tr   { page-break-inside: avoid; page-break-after: auto; }
    thead { display: table-header-group; }
    h1, h2, h3, h4 { page-break-after: avoid; }
}
a { color: #1864ab; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1f2d3d;
    color: #fff;
    padding: 0 20px;
    height: 56px;
}
.topbar a { color: #fff; }
.brand a { font-weight: 700; font-size: 1.15rem; display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-logo { height: 36px; width: auto; display: block; background: transparent; }
.brand-text { color: #fff; }
.mainnav a { margin: 0 10px; font-size: 0.95rem; }
.user span { margin-left: 12px; opacity: 0.85; }

.container {
    max-width: 1500px;
    margin: 24px auto;
    padding: 0 20px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 20px;
}
.card {
    background: #fff;
    border: 1px solid #e3e6ea;
    border-radius: 8px;
    padding: 18px;
    color: #222;
    transition: transform 0.1s, box-shadow 0.1s;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    text-decoration: none;
}
.card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.card p { margin: 0; color: #666; font-size: 0.9rem; }

.alert {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    border: 1px solid transparent;
}
.alert.success { background: #e6f7ee; color: #1b6e3a; border-color: #b8e1c8; }
.alert.error   { background: #fdecea; color: #9b2c2c; border-color: #f5c2c0; }

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e3e6ea;
    border-radius: 6px;
    overflow: hidden;
}
th, td { padding: 10px 12px; border-bottom: 1px solid #eef0f3; text-align: right; }
th { background: #fafbfc; font-weight: 600; }

.btn {
    display: inline-block;
    background: #1864ab;
    color: #fff;
    padding: 8px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
}
.btn:hover { background: #134f87; text-decoration: none; }
.btn.danger { background: #c0392b; }
.btn.secondary { background: #6c757d; }

input[type=text], input[type=password], input[type=email],
input[type=number], input[type=date], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccd1d9;
    border-radius: 6px;
    font-size: 0.95rem;
    margin-top: 4px;
}

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1f2d3d;
}
.login-box {
    background: #fff;
    padding: 28px 32px;
    border-radius: 10px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.login-box h1 { margin: 0 0 4px; text-align: center; color: #1864ab; }
.login-box h2 { margin: 0 0 20px; text-align: center; font-weight: 400; color: #555; }
.login-box label { display: block; margin-bottom: 14px; font-size: 0.9rem; color: #444; }
.login-box button {
    width: 100%;
    background: #1864ab;
    color: #fff;
    padding: 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
}

.footer {
    text-align: center;
    padding: 20px;
    color: #888;
}

.error-page { text-align: center; padding: 80px 20px; }
.error-page h1 { font-size: 5rem; margin: 0; color: #1864ab; }

/* Dropdown nav */
.mainnav { display: flex; align-items: center; gap: 4px; }
.dropdown { position: relative; }
.dropdown .dd-toggle { padding: 8px 12px; display: inline-block; cursor: pointer; }
.dropdown .dd-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: #2c3e50;
    min-width: 180px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
    border-radius: 6px;
    display: none;
    z-index: 100;
    padding: 6px 0;
}
.dropdown:hover .dd-menu { display: block; }
.dropdown .dd-menu a {
    display: block;
    padding: 8px 14px;
    color: #fff;
    font-size: 0.92rem;
    margin: 0;
    white-space: nowrap;
}
.dropdown .dd-menu a:hover { background: #1864ab; text-decoration: none; }

/* Forms layout */
form label { display: block; margin-bottom: 12px; font-size: 0.92rem; color: #444; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-section { background: #fff; border: 1px solid #e3e6ea; border-radius: 8px; padding: 18px; margin-bottom: 16px; }
.form-section h3 { margin: 0 0 12px; font-size: 1rem; color: #1864ab; border-bottom: 1px solid #eef0f3; padding-bottom: 6px; }

/* ========== Filter Card (listing pages) ========== */
.filter-card {
    background: #fff;
    border: 1px solid #e3e6ea;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.filter-row {
    display: grid;
    grid-template-columns: 2.4fr 1fr 1fr 1fr 1.2fr auto;
    gap: 10px;
    align-items: end;
}
.filter-row .fc-field { display: flex; flex-direction: column; gap: 4px; }
.filter-row-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
}
.filter-row-flex .fc-field { display: flex; flex-direction: column; gap: 4px; min-width: 140px; flex: 1 1 160px; }
.filter-row-flex .fc-search { flex: 2 1 280px; }
.filter-row-flex input, .filter-row-flex select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 13px;
    margin: 0;
    background: #fff;
}
.filter-row-flex label.fc-lbl { font-size: 11px; font-weight: 600; color: #495057; margin: 0; }
.filter-row label.fc-lbl { font-size: 11px; font-weight: 600; color: #495057; margin: 0; }
.filter-row input, .filter-row select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 13px;
    margin: 0;
    background: #fff;
}
.filter-row input:focus, .filter-row select:focus {
    border-color: #1864ab;
    outline: none;
    box-shadow: 0 0 0 2px rgba(24,100,171,.15);
}
.filter-row select:disabled { background: #f1f3f5; color: #adb5bd; cursor: not-allowed; }
.fc-search input {
    font-size: 14px !important;
    font-weight: 500;
    height: 36px !important;
    padding: 7px 12px 7px 34px !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%231864ab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
    background-repeat: no-repeat;
    background-position: 10px center;
}
.fc-reset {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #ced4da;
    padding: 7px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.fc-reset:hover { background: #e9ecef; color: #c92a2a; text-decoration: none; }
.fc-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed #e9ecef;
}
.fc-count {
    font-size: 13px;
    color: #495057;
    font-weight: 600;
}
.fc-count strong { color: #1864ab; }
.fc-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.fc-chip {
    background: #e7f5ff;
    color: #1864ab;
    border: 1px solid #74c0fc;
    padding: 3px 8px 3px 6px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.fc-chip a { color: #1864ab; font-weight: 700; text-decoration: none; padding: 0 2px; }
.fc-chip a:hover { color: #c92a2a; }
.fc-adv-toggle {
    background: #fff;
    border: 1px solid #74c0fc;
    color: #1864ab;
    padding: 7px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    height: 34px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.fc-adv-toggle:hover { background: #e7f5ff; }
.fc-adv-toggle.active { background: #1864ab; color: #fff; border-color: #1864ab; }
.fc-adv-panel {
    margin-top: 10px;
    padding: 10px 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}
.fc-adv-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.fc-adv-grid .fc-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #495057;
    padding: 6px 8px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
}
.fc-adv-grid .fc-check input { width: auto; margin: 0; }
.fc-adv-grid .fc-check:hover { border-color: #74c0fc; background: #e7f5ff; }

@media (max-width: 980px) {
    .filter-row { grid-template-columns: 1fr 1fr; }
    .fc-search { grid-column: span 2; }
    .fc-adv-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-row .fc-reset, .filter-row .fc-adv-toggle { grid-column: auto; }
}
@media (max-width: 540px) {
    .filter-row { grid-template-columns: 1fr; }
    .fc-search { grid-column: span 1; }
    .fc-adv-grid { grid-template-columns: 1fr; }
}

/* ========== Pretty product table ========== */
.table-pretty { background: #fff; border: 1px solid #e3e6ea; border-radius: 10px; overflow: hidden; }
.table-pretty th { background: #f1f5f9; color: #1864ab; font-size: 12px; text-transform: none; }
.table-pretty td { font-size: 13px; vertical-align: middle; }
.table-pretty tbody tr:hover { background: #f8fbff; }
.table-pretty code {
    white-space: nowrap;
    font-size: 12px;
    background: #f1f3f5;
    padding: 2px 6px;
    border-radius: 4px;
    color: #1864ab;
    font-family: "Consolas", "Menlo", monospace;
    direction: ltr;
    display: inline-block;
}
.tp-img {
    width: 48px; height: 48px;
    object-fit: contain;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 2px;
    display: block;
}
.tp-empty { color: #adb5bd; font-style: italic; }
.tp-price { font-variant-numeric: tabular-nums; font-weight: 600; color: #212529; white-space: nowrap; }
.tp-price small { color: #868e96; font-weight: 400; margin-right: 3px; font-size: 10px; }
.tp-qty-out {
    display: inline-block;
    background: #ffe3e3;
    color: #c92a2a;
    font-weight: 700;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid #ffc9c9;
    white-space: nowrap;
}
.tp-actions { display: inline-flex; gap: 6px; flex-wrap: nowrap; justify-content: center; }
.tp-actions a {
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    min-width: 44px;
    text-align: center;
}
.tp-actions a.act-view { background: #e7f5ff; color: #1864ab; border-color: #d0ebff; }
.tp-actions a.act-edit { background: #fff4e6; color: #d9480f; border-color: #ffd8a8; }
.tp-actions a.act-del  { background: #ffe3e3; color: #c92a2a; border-color: #ffc9c9; }
.tp-actions a:hover { text-decoration: none; filter: brightness(.95); }

/* ========== Mobile nav (hamburger) ========== */
.nav-toggle {
    display: none;
    background: transparent;
    border: 0;
    width: 40px;
    height: 40px;
    padding: 8px;
    cursor: pointer;
    flex-direction: column;
    justify-content: space-between;
}
.nav-toggle span {
    display: block;
    height: 3px;
    background: #fff;
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

@media (max-width: 900px) {
    .topbar {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 12px;
        gap: 8px;
    }
    .brand { flex: 1; }
    .brand a { font-size: 1rem; }
    .brand-logo { height: 30px; }
    .nav-toggle { display: flex; }

    .mainnav {
        order: 10;
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height .25s ease;
        background: #1a2533;
        border-radius: 6px;
        margin-top: 4px;
    }
    .mainnav.open {
        max-height: calc(100vh - 60px);
        overflow-y: auto;
        padding: 6px 0;
    }
    .mainnav > a,
    .mainnav .dropdown > .dd-toggle {
        display: block;
        padding: 12px 14px;
        margin: 0;
        border-bottom: 1px solid #2a3a4d;
        font-size: 1rem;
    }
    .dropdown { position: static; }
    .dropdown .dd-menu {
        position: static;
        display: none;
        box-shadow: none;
        border-radius: 0;
        background: #15202d;
        min-width: 0;
        padding: 0;
    }
    .dropdown.open > .dd-menu { display: block; }
    .dropdown:hover .dd-menu { display: none; }
    .dropdown.open > .dd-menu { display: block; }
    .dropdown .dd-menu a {
        padding: 10px 28px;
        font-size: .95rem;
        border-bottom: 1px solid #20303f;
    }

    .user {
        order: 11;
        flex-basis: 100%;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px;
        padding: 8px 4px 0;
        border-top: 1px solid #2a3a4d;
        font-size: .85rem;
    }
    .user span { margin: 0 !important; }

    .container { padding: 0 10px; margin: 14px auto; }
    .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .card { padding: 12px; }
    .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }

    /* Tables become horizontally scrollable on phones */
    table { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 480px) {
    .brand-text { display: none; }
    .cards { grid-template-columns: repeat(2, 1fr); }
}
