/* assets/css/reports.css - Ultra-Dense Clean Version (Restored) */

:root {
    --report-bg: #f8fafc;
    --report-primary: #1e60d2;
    --report-text: #1e293b;
    --report-muted: #64748b;
    --report-border: #e2e8f0;
    --report-radius: 4px;
    /* Back to sharp-ish corners */
}

.bg-light-danger {
    background-color: #fef2f2 !important;
}

body {
    background-color: var(--report-bg);
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.report-container {
    padding: 1rem;
    max-width: 1700px;
    margin: 0 auto;
}

.report-header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.report-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
}

/* Stats Grid - Keeping the 2-column density as it was the best mobile version */
.report-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.report-stat-card {
    background: #fff;
    border: 1px solid var(--report-border);
    padding: 0.75rem;
    border-radius: var(--report-radius);
    display: flex;
    flex-direction: column;
}

.report-stat-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--report-muted);
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.report-stat-value {
    font-size: 1.15rem;
    font-weight: 700;
}

.report-filter-toggle {
    display: none;
}

/* Filters */
.report-filter-bar {
    background: #fff;
    border: 1px solid var(--report-border);
    padding: 1rem;
    border-radius: var(--report-radius);
    margin-bottom: 1rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.report-filter-group {
    flex: 1;
    min-width: 140px;
}

.report-filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--report-muted);
    display: block;
    margin-bottom: 0.25rem;
}

.report-filter-group input,
.report-filter-group select {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--report-border);
    border-radius: var(--report-radius);
    font-size: 0.85rem;
    outline: none;
}

/* Table */
.report-table-wrapper {
    background: #fff;
    border: 1px solid var(--report-border);
    border-radius: var(--report-radius);
    overflow: hidden;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
}

.report-table th {
    background: #f8fafc;
    padding: 0.75rem;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--report-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--report-border);
}

.report-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--report-border);
    font-size: 0.85rem;
}

.report-table tr:hover {
    background: #fbfcfd;
}

/* Pagination */
.report-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
}

.pagination-btn {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--report-border);
    background: #fff;
    border-radius: var(--report-radius);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* MOBILE: Premium Ultra-Dense Card Layout (Generic) */
@media (max-width: 768px) {
    .report-container {
        padding: 0.75rem;
    }

    .report-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .report-header-section {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .report-title h1 {
        font-size: 1.1rem;
    }

    .report-title p {
        display: none;
    }

    .report-actions {
        gap: 0.25rem;
    }

    .report-actions .pagination-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
    }

    .report-filter-bar {
        display: none;
        padding: 0.6rem 0.75rem;
        gap: 0.5rem 0.75rem;
        align-items: stretch;
    }

    .report-filter-bar.show {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .report-filter-toggle {
        display: block !important;
        width: 100%;
        margin-bottom: 0.5rem;
        background: #fff;
        font-size: 0.75rem;
        padding: 0.65rem;
        font-weight: 600;
        border: 1px solid var(--report-border);
        border-radius: var(--report-radius);
        color: var(--report-text);
        text-align: center;
        cursor: pointer;
    }

    .report-filter-group {
        grid-column: span 2;
        margin-bottom: 0.25rem;
    }

    /* Explicit class for elements that should share a row on mobile */
    .report-filter-group.date-group {
        grid-column: span 1;
    }

    .report-filter-bar select,
    .report-filter-bar input {
        height: 38px;
        font-size: 0.85rem;
    }

    .report-filter-bar button {
        width: 100%;
        margin-top: 0.25rem;
        height: 40px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .report-table-wrapper {
        border: none;
        background: transparent;
        overflow: visible;
    }

    .report-table,
    .report-table thead,
    .report-table tbody,
    .report-table th,
    .report-table td,
    .report-table tr {
        display: block;
    }

    .report-table thead {
        display: none;
    }

    .report-table tr {
        background: #fff;
        border: 1px solid var(--report-border);
        border-radius: 8px;
        padding: 8px 10px;
        margin-bottom: 6px;
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "primary total"
            "meta total"
            "details taxable"
            "action gst";
        gap: 0px 12px;
        position: relative;
        transition: transform 0.1s;
    }

    .report-table tr:active {
        transform: scale(0.98);
        background: #fcfdfe;
    }

    .report-table td {
        border: none !important;
        padding: 0 !important;
        min-height: auto;
    }

    /* Area 1: Primary Info (Vendor/Item) */
    .report-table td:nth-child(1) {
        grid-area: primary;
        align-self: end;
    }

    .report-table td:nth-child(1) .fw-bold {
        font-size: 0.95rem;
        color: var(--report-text);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 180px;
    }

    .report-table td:nth-child(1) .text-muted {
        font-size: 0.7rem !important;
        font-weight: 500;
    }

    /* Area 2: Total Price Box (Targeted by Class) */
    .report-table td.report-total-amount {
        grid-area: total;
        grid-row: span 2;
        text-align: right !important;
        align-self: center;
        display: flex !important;
        flex-direction: column;
        align-items: flex-end;
        background: #f0f7ff;
        padding: 4px 10px !important;
        border-radius: 6px;
        font-size: 0.95rem !important;
        font-weight: 800 !important;
        border: 1px solid #e0efff !important;
        min-width: 90px;
        z-index: 2;
    }

    /* Target based on label only as fallback */
    .report-table td[data-label="Amount"]:not(.report-total-amount) {
        grid-area: total;
    }

    /* Area 3: Sub-primary Meta Info (Second Column) */
    .report-table td:nth-child(2),
    .report-table td[data-label*="Category"] {
        grid-area: meta;
        font-size: 0.75rem;
        display: flex !important;
        align-items: center;
        gap: 6px;
        align-self: start;
    }

    .report-table td:nth-child(2) .fw-bold {
        font-size: 0.72rem;
        color: var(--report-muted);
        font-weight: 600 !important;
    }

    .report-table td:nth-child(2) .text-muted {
        font-size: 0.72rem !important;
        opacity: 0.8;
    }

    .report-table td:nth-child(2) .text-muted::before {
        content: "•";
        margin-right: 6px;
        opacity: 0.5;
    }

    /* Area 2b: Secondary Metrics (Middle Right) */
    .report-table td[data-label*="Taxable"],
    .report-table td[data-label*="Orders"],
    .report-table td[data-label*="Net Business"],
    .report-table td[data-label*="Type"],
    .report-table td[data-label*="Debit"],
    .report-table td[data-label*="Revenue"],
    .report-table td[data-label*="Activity"],
    .report-table td[data-label*="Billed"],
    .report-table td[data-label*="Purchased"],
    .report-table td[data-label*="Total Amount"] {
        grid-area: taxable;
        display: flex !important;
        justify-content: flex-end;
        align-items: center;
        font-size: 0.72rem;
        font-weight: 700;
        color: var(--report-text);
        margin-top: 2px;
    }

    /* Area 3: Actions & Status Hub (Bottom Center/Right) */
    .report-table td[data-label*="Status"],
    .report-table td[data-label*="Avg Rate"],
    .report-table td[data-label*="Paid"],
    .report-table td[data-label*="Collected"],
    .report-table td.report-action-cell {
        grid-area: action;
        display: flex !important;
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        gap: 12px;
        border-top: 1px dashed #f1f5f9 !important;
        padding-top: 6px !important;
        margin-top: 6px;
        width: 100%;
        background: transparent !important;
        border-radius: 0 !important;
    }

    /* Area 2c: Tax & GST (Bottom Right - Dedicated Zone) */
    .report-table td[data-label*="GST"],
    .report-table td[data-label*="Tax Paid"],
    .report-table td[data-label*="Credit"],
    .report-table td[data-label*="Margin"],
    .report-table td[data-label*="Received"],
    .report-table td[data-label*="Paid"] {
        grid-area: gst;
        display: flex !important;
        justify-content: flex-end;
        align-items: center;
        text-align: right;
        font-size: 0.72rem;
        font-weight: 700;
        margin-top: 2px;
    }

    /* Area 4: High-Density Details (Bottom Left) */
    .report-table td[data-label*="Outstanding"],
    .report-table td[data-label*="Qty Sold"],
    .report-table td[data-label*="Total Item"],
    .report-table td:not(:first-child):not(:nth-child(2)):not(:last-child):not([data-label*="Taxable"]):not([data-label*="Orders"]):not([data-label*="Paid"]):not([data-label*="Collected"]):not([data-label*="Net Business"]):not([data-label*="Status"]):not([data-label*="Avg Rate"]):not([data-label*="GST"]):not([data-label*="Tax Paid"]):not([data-label*="Debit"]):not([data-label*="Credit"]) {
        grid-area: details;
        display: flex !important;
        flex-wrap: wrap;
        gap: 8px;
        font-size: 0.68rem;
        color: var(--report-muted);
        margin-top: 4px;
        padding-top: 4px !important;
        border-top: 1px dashed #f1f5f9 !important;
    }

    /* GST/Tax specific styling inside hubs */
    .report-table td[data-label*="GST"],
    .report-table td[data-label*="Tax Paid"],
    .report-table td[data-label*="Debit"] {
        color: #ef4444 !important;
        font-weight: 700 !important;
        font-size: 0.72rem !important;
    }

    /* Credit specific branding (Green) */
    .report-table td[data-label*="Credit"] {
        color: #10b981 !important;
        font-weight: 700 !important;
        font-size: 0.72rem !important;
    }

    /* Handle labels dynamically from data-label (Exclude meta-row and total-box for clean look) */
    .report-table td:not(:first-child):not(:nth-child(2)):not(:last-child):not(.report-total-amount)::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        margin-right: 3px;
        color: var(--report-muted);
        opacity: 0.8;
    }

    /* Special label colors */
    .report-table td[data-label*="GST"]::before,
    .report-table td[data-label*="Tax Paid"]::before {
        color: #ef4444;
        opacity: 0.7;
    }

    .report-pagination {
        margin-top: 0.5rem;
        background: #fff;
        border-radius: 6px;
        border: 1px solid var(--report-border);
    }
}

/* Guide Section */
/* Guide Section - Custom Implementation (No Bootstrap) */
.guide-card {
    background: #fff;
    border: 1px solid var(--report-border);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1.5rem;
}

.guide-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.guide-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    color: var(--report-text);
    display: flex;
    align-items: center;
}

.lang-toggle {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 10px;
    gap: 4px;
    width: fit-content;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.03);
}

.lang-btn {
    padding: 6px 18px;
    font-size: 0.72rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border: none;
    background: transparent;
    border-radius: 7px;
    cursor: pointer;
    color: var(--report-muted);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.lang-btn.active {
    background: #fff;
    color: var(--report-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
}

.lang-btn:hover:not(.active) {
    color: var(--report-text);
    background: rgba(255, 255, 255, 0.4);
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.guide-item {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    height: 100%;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.guide-item:hover {
    border-color: #e2e8f0;
    background: #fff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.guide-item h4 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--report-primary);
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
}

.guide-item p {
    font-size: 0.78rem;
    color: var(--report-muted);
    line-height: 1.5;
    margin: 0;
}

/* Guide Responsive */
@media (max-width: 992px) {
    .guide-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .guide-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .lang-toggle {
        width: 100%;
        justify-content: stretch;
    }

    .lang-btn {
        flex: 1;
    }

    .guide-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .guide-card {
        padding: 0.75rem;
    }
}

.text-right {
    text-align: right !important;
}

.text-danger {
    color: #ef4444 !important;
}

.text-success {
    color: #10b981 !important;
}

/* Empty State Styling */
.report-empty-state {
    padding: 3rem 1rem;
    text-align: center;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.empty-icon-circle {
    width: 64px;
    height: 64px;
    background: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    color: var(--report-muted);
    font-size: 1.5rem;
    opacity: 0.6;
}

.report-empty-state h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--report-text);
    margin: 0 0 0.25rem 0;
}

.report-empty-state p {
    font-size: 0.8rem;
    color: var(--report-muted);
    margin: 0;
}

@media (max-width: 768px) {
    .report-empty-state {
        padding: 2.5rem 1rem;
        border: 1px solid var(--report-border);
        border-radius: 8px;
        margin-top: 10px;
    }
}

.fw-bold {
    font-weight: 700 !important;
}

/* Premium Status Badges */
.s-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    border: 1px solid transparent;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.s-badge i {
    font-size: 0.8rem;
    opacity: 0.8;
}

/* Badge Themes (Subtle Backgrounds with Strong Text) */
.s-badge.bg-success {
    background: #ecfdf5 !important;
    color: #065f46 !important;
    border-color: #d1fae5 !important;
}

.s-badge.bg-warning {
    background: #fffbeb !important;
    color: #92400e !important;
    border-color: #fef3c7 !important;
}

.s-badge.bg-danger {
    background: #fef2f2 !important;
    color: #991b1b !important;
    border-color: #fee2e2 !important;
}

.s-badge.bg-primary {
    background: #eff6ff !important;
    color: #1e40af !important;
    border-color: #dbeafe !important;
}

.s-badge.bg-muted {
    background: #f8fafc !important;
    color: #475569 !important;
    border-color: #e2e8f0 !important;
}

font-size: 0.6rem !important;
font-weight: 800 !important;
color: var(--report-muted) !important;
margin-bottom: 2px !important;
}

/* Center Section: Party Info */
.sale-order-table td[data-label*="Party"] {
    grid-area: meta !important;
    display: block !important;
    padding: 12px 0 !important;
    margin: 12px 0 !important;
    border-top: 1px dashed #e2e8f0 !important;
    border-bottom: 1px dashed #e2e8f0 !important;
}

.sale-order-table td[data-label*="Party"] .fw-bold {
    font-size: 1.05rem !important;
    color: #1a202c !important;
}

/* FORCE HIDE: Type label (High Specificity) */
.report-container .report-table.sale-order-table td[data-label*="Type"],
.report-container .report-table.sale-order-table td[data-label="Type"] {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Bottom Left: Status (Pinned Left) */
.sale-order-table td[data-label*="Status"] {
    grid-area: status !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 10px 0 0 0 !important;
}

.sale-order-table td[data-label*="Status"]::before {
    content: "STATUS" !important;
    font-size: 0.65rem !important;
    font-weight: 850 !important;
    color: var(--report-muted) !important;
    margin-right: 10px !important;
}

/* Bottom Right: Action (Pinned Right) */
.sale-order-table td.report-action-cell {
    grid-area: action !important;
    display: flex !important;
    justify-content: flex-end !important;
    padding: 10px 0 0 0 !important;
}

.sale-order-table td.report-action-cell button {
    background: var(--report-primary) !important;
    border: none !important;
    color: #ffffff !important;
    font-weight: 800 !important;
    height: 36px !important;
    padding: 0 20px !important;
    font-size: 0.85rem !important;
    border-radius: 10px !important;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.2) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}
}