/*
 * =========================================================
 * DATAWISE RESPONSIVE GRID
 * Version 1.2
 *
 * Generic responsive presentation for legacy Datawise Grids
 *
 * Mobile philosophy:
 * - Clean, readable typography
 * - Compact list instead of desktop table
 * - Large touch targets
 * - Detail bottom sheet
 * - Generic actions area
 * - Desktop Grid remains untouched
 * =========================================================
 */


/* =========================================================
   DETAIL SHEET - DEFAULT HIDDEN
   ========================================================= */

.dw-rg-detail-overlay,
.dw-rg-detail-sheet {
    display: none;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 767px) {


    /* =====================================================
       GRID
       ===================================================== */

    .dw-rg-grid {
        display: block;

        width: 100% !important;
        max-width: 100%;

        height: auto !important;

        margin: 0;

        background: #ffffff;

        border: 1px solid #e2e7ea;
        border-radius: 7px;

        overflow: hidden;

        box-sizing: border-box;
    }


    .dw-rg-grid thead {
        display: none;
    }


    .dw-rg-grid tbody {
        display: block;

        width: 100%;
        height: auto;

        margin: 0;
        padding: 0;

        background: #ffffff;

        box-sizing: border-box;
    }


    /* =====================================================
       ROW
       ===================================================== */

    .dw-rg-grid tbody tr.dw-rg-row {
        display: grid;

        grid-template-columns:
            minmax(0, 1fr)
            auto;

        width: 100%;

        margin: 0;

        padding: 13px 14px;

        background: #ffffff;

        border: 0;
        border-bottom: 1px solid #e8ecef;

        border-radius: 0;

        box-shadow: none;

        cursor: pointer;

        box-sizing: border-box;
    }


    .dw-rg-grid tbody tr.dw-rg-row:last-child {
        border-bottom: 0;
    }


    .dw-rg-grid tbody td {
        display: block;

        width: auto !important;
        min-width: 0;

        margin: 0;
        padding: 0;

        border: 0 !important;

        background: transparent;

        white-space: normal;

        box-sizing: border-box;
    }


    /* =====================================================
       HIDDEN MOBILE FIELDS
       ===================================================== */

    .dw-rg-mobile-hidden {
        display: none !important;
    }


    .dw-rg-hide-mobile {
        display: none !important;
    }


    /* =====================================================
       PRIMARY LEFT
       π.χ. Τράπεζα / Πελάτης
       ===================================================== */

    .dw-rg-primary-left {
        display: block !important;

        grid-column: 1;
        grid-row: 1;

        min-width: 0;

        padding-right: 12px;

        font-size: 13px;
        line-height: 1.3;
        font-weight: 600;

        color: #657078;

        overflow-wrap: anywhere;
    }


    /* =====================================================
       PRIMARY RIGHT
       π.χ. Ποσό
       ===================================================== */

    .dw-rg-primary-right {
        display: block !important;

        grid-column: 2;
        grid-row: 1;

        font-size: 18px;
        line-height: 1.15;
        font-weight: 700;

        letter-spacing: -0.2px;

        color: #202a32;

        text-align: right;

        white-space: nowrap !important;
    }


    /* Credit */

    .dw-rg-credit {
        color: #2f7d5b !important;
    }


    /* Debit */

    .dw-rg-debit {
        color: #b84c4c !important;
    }


    /* =====================================================
       SECONDARY LEFT
       π.χ. Ημερομηνία / Εταιρεία
       ===================================================== */

    .dw-rg-secondary-left {
        display: block !important;

        grid-column: 1;
        grid-row: 2;

        min-width: 0;

        margin-top: 5px;

        padding-right: 10px;

        font-size: 12px;
        line-height: 1.35;
        font-weight: 400;

        color: #8a949a;
    }


    /* =====================================================
       SECONDARY RIGHT
       π.χ. Υπόλοιπο / Status
       ===================================================== */

    .dw-rg-secondary-right {
        display: block !important;

        grid-column: 2;
        grid-row: 2;

        margin-top: 5px;

        font-size: 12px;
        line-height: 1.35;
        font-weight: 600;

        color: #5b6770;

        text-align: right;

        white-space: nowrap !important;
    }


    .dw-rg-secondary-right[data-dw-label]:before {
        content: attr(data-dw-label);

        font-size: 12px;
        font-weight: 400;

        color: #9aa3a9;
    }


    /* =====================================================
       DESCRIPTION
       ===================================================== */

    .dw-rg-description {
        display: block !important;

        grid-column: 1 / -1;
        grid-row: 3;

        min-width: 0;

        margin-top: 8px;

        font-size: 13px;
        line-height: 1.4;
        font-weight: 400;

        color: #303b43;

        overflow-wrap: anywhere;
    }


    /* =====================================================
       PAGINATION
       ===================================================== */

    .paggination {
        display: block;

        width: 100%;
        max-width: 100%;

        margin-top: 10px;

        overflow-x: auto;
        overflow-y: hidden;

        white-space: nowrap;

        -webkit-overflow-scrolling: touch;

        scrollbar-width: none;

        box-sizing: border-box;
    }


    .paggination::-webkit-scrollbar {
        display: none;
    }


    .paggination > * {
        float: none !important;

        display: inline-block !important;

        vertical-align: top;
    }


    /* =====================================================
       DETAIL OVERLAY
       ===================================================== */

    .dw-rg-detail-overlay {
        position: fixed;

        z-index: 2000;

        top: 0;
        right: 0;
        bottom: 0;
        left: 0;

        display: block;

        background: rgba(20, 28, 34, 0.42);

        opacity: 0;

        pointer-events: none;

        transition: opacity 180ms ease;
    }


    .dw-rg-detail-overlay.is-open {
        opacity: 1;

        pointer-events: auto;
    }


    /* =====================================================
       DETAIL SHEET
       ===================================================== */

    .dw-rg-detail-sheet {
        position: fixed;

        z-index: 2010;

        left: 0;
        right: 0;
        bottom: 0;

        display: block;

        max-height: calc(100dvh - 20px);

        padding-top:
            env(safe-area-inset-top);

        background: #ffffff;

        border-radius:
            16px 16px 0 0;

        box-shadow:
            0 -8px 28px
            rgba(20, 35, 45, 0.16);

        transform:
            translateY(105%);

        transition:
            transform 220ms ease;

        overflow: hidden;
    }


    .dw-rg-detail-sheet.is-open {
        transform:
            translateY(0);
    }


    /* =====================================================
       SHEET HANDLE
       ===================================================== */

    .dw-rg-detail-handle {
        width: 38px;
        height: 4px;

        margin: 8px auto 3px;

        border-radius: 999px;

        background: #d5dadd;
    }


    /* =====================================================
       SHEET HEADER
       ===================================================== */

    .dw-rg-detail-header {
        display: flex;

        align-items: center;
        justify-content: space-between;

        gap: 15px;

        padding: 12px 18px;

        border-bottom: 1px solid #edf0f2;

        background: #ffffff;
    }


    .dw-rg-detail-title {
        font-size: 18px;
        line-height: 1.25;
        font-weight: 700;

        color: #202a32;
    }


    .dw-rg-detail-subtitle {
        margin-top: 3px;

        font-size: 13px;
        line-height: 1.4;
        font-weight: 600;

        color: #657078;
    }


    /* =====================================================
       SHEET HEADER ACTIONS
       ===================================================== */

    .dw-rg-detail-header-actions {
        flex: 0 0 auto;

        display: flex;
        align-items: center;

        gap: 7px;
    }


    /* =====================================================
       MORE ACTIONS BUTTON
       ===================================================== */

    .dw-rg-detail-more {
        flex: 0 0 auto;

        width: 36px;
        height: 36px;

        padding: 0;

        display: flex;
        align-items: center;
        justify-content: center;

        gap: 3px;

        border: 0;
        border-radius: 50%;

        background: #f2f4f5;

        cursor: pointer;

        box-sizing: border-box;

        -webkit-appearance: none;
        appearance: none;
    }


    /* Three dots */

    .dw-rg-detail-more span {
        display: block;

        flex: 0 0 4px;

        width: 4px;
        height: 4px;

        margin: 0;
        padding: 0;

        border-radius: 50%;

        background: #4e5961;
    }

	/* =====================================================
	   MOBILE ACTIONS MENU
	   ===================================================== */

	.dw-rg-detail-header-actions {
		position: relative;
	}


	.dw-rg-actions-menu {
		position: absolute;

		top: 44px;
		right: 43px;

		display: none;

		min-width: 190px;

		padding: 5px 0;

		background: #ffffff;

		border: 1px solid #e1e6e9;
		border-radius: 11px;

		box-shadow:
			0 8px 26px
			rgba(20, 35, 45, 0.16);

		overflow: hidden;

		z-index: 10;
	}


	.dw-rg-actions-menu.is-open {
		display: block;
	}


	.dw-rg-action {
		display: block;

		width: 100%;

		padding: 11px 15px;

		border: 0;

		background: #ffffff;

		color: #303b43;

		font-size: 13px;
		line-height: 1.35;
		font-weight: 500;

		text-align: left;

		cursor: pointer;

		box-sizing: border-box;

		-webkit-appearance: none;
		appearance: none;
	}


	.dw-rg-action:active {
		background: #f5f7f8;
	}


	.dw-rg-action + .dw-rg-action {
		border-top: 1px solid #f0f2f3;
	}


	.dw-rg-action-separator {
		margin-top: 4px;

		border-top:
			1px solid #e1e6e9 !important;
	}


	.dw-rg-action-danger {
		color: #b84c4c;
	}


	.dw-rg-detail-more.is-open {
		background: #e8ecef;
	}
    /* =====================================================
       CLOSE BUTTON
       ===================================================== */

   .dw-rg-detail-close {
		flex: 0 0 auto;

		width: 36px;
		height: 36px;

		padding: 0 0 3px 0;

		display: flex;
		align-items: center;
		justify-content: center;

		border: 0;
		border-radius: 50%;

		background: #f2f4f5;
		color: #4e5961;

		font-size: 30px;
		font-weight: 400;
		line-height: 1;

		cursor: pointer;

		box-sizing: border-box;

		-webkit-appearance: none;
		appearance: none;
	}


    /* =====================================================
       SHEET BODY
       ===================================================== */

    .dw-rg-detail-body {
        max-height: calc(
            100dvh
            - 90px
            - env(safe-area-inset-top)
            - env(safe-area-inset-bottom)
        );

        padding:
            14px
            18px
            calc(
                34px +
                env(safe-area-inset-bottom)
            );

        overflow-y: auto;

        -webkit-overflow-scrolling: touch;
    }


    /* =====================================================
       DETAIL HIGHLIGHTS
       ===================================================== */

    .dw-rg-detail-highlights {
        display: grid;

        grid-template-columns:
            repeat(
                2,
                minmax(0, 1fr)
            );

        gap: 12px;

        margin-bottom: 14px;
        padding-bottom: 14px;

        border-bottom:
            1px solid #edf0f2;
    }


    .dw-rg-detail-highlight {
        min-width: 0;
    }


    .dw-rg-detail-highlight:last-child {
        text-align: right;
    }


    .dw-rg-detail-label {
        margin-bottom: 4px;

        font-size: 12px;
        line-height: 1.3;
        font-weight: 600;

        color: #909aa1;
    }


    .dw-rg-detail-highlight-value {
        font-size: 18px;
        line-height: 1.25;
        font-weight: 700;

        color: #303b43;

        overflow-wrap: anywhere;
    }


    .dw-rg-detail-highlight:first-child
    .dw-rg-detail-highlight-value {
        font-size: 22px;
    }


    /* =====================================================
       DETAIL ROW
       ===================================================== */

    .dw-rg-detail-row {
        display: flex;

        align-items: flex-start;
        justify-content: space-between;

        gap: 20px;

        padding: 10px 0;

        border-bottom:
            1px solid #f0f2f3;
    }


    .dw-rg-detail-row span {
        flex: 0 0 38%;

        font-size: 13px;
        line-height: 1.4;

        color: #8a949a;
    }


    .dw-rg-detail-row strong {
        flex: 1 1 auto;

        min-width: 0;

        font-size: 13px;
        line-height: 1.4;
        font-weight: 600;

        color: #303b43;

        text-align: right;

        overflow-wrap: anywhere;
    }


    /* =====================================================
       LONG TEXT DETAIL SECTION
       ===================================================== */

    .dw-rg-detail-section {
        margin-top: 14px;
        padding-top: 12px;

        border-top:
            1px solid #edf0f2;

        font-size: 13px;
        line-height: 1.5;

        color: #303b43;

        overflow-wrap: anywhere;
    }


    /*
     * Avoid double separator.
     * Previous detail row already has border-bottom.
     */

    .dw-rg-detail-row +
    .dw-rg-detail-section {
        border-top: 0;
    }

    /*
     * Desktop Grid Tools do not belong in the mobile card layout.
     * Filters/columns/page-size/views remain desktop/table controls.
     */
    .dw-grid-tools {
        display: none !important;
    }
}