﻿body {
	margin: 0;
	font-family: Arial, sans-serif;
	height: 100vh;
	display: flex;
	flex-direction: column;
	position: relative;
}

.filters {
	position: relative;
	display: flex;
	align-items: center;
	padding: 10px;
	background: #f9f9f9;
	border-bottom: 1px solid #ccc;
}

.filter-group {
	display: flex;
	gap: 10px;
	z-index: 2;
}

.filter-group select {
	max-width: 120px;
}

#filterEstimator {
    width: 75px;
}

#filterTech {
    width: 70px;
}

#filterIns {
    width: 80px;
}

#filterPhase {
    width: 80px;
}

#filterSublet {
    width: 80px;
}

.main-select-center {
    position: absolute;
    left: 50%;
    top: 10px; /* same as .filters padding, so tops line up with the left dropdowns */
    transform: translateX(-50%);
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center; /* dropdown and search centered on each other */
    gap: 4px;
}

    /* Search under the main dropdown: a bit wider than the dropdown */
    .main-select-center #searchContainer {
        width: 280px !important;
    }

/* Refresh + main dropdown row

/* Refresh + main dropdown row; the refresh button positions against this row */
.main-select-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}

#viewAllButton {
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-right: 15px;
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
    user-select: none;
}

.action-buttons-right {
    position: absolute;
    top: 10px; 
    right: 20px;
    margin: 0;
    z-index: 4;
}

#mainFilterSelect, .record-count
.main-Filter-Select {
    width: 200px;
    font-size: 1rem;
    padding: 5px;
    text-align: center;
}

.sales-holder {
	margin-left: auto;
	min-width: 160px;
	text-align: right;
	z-index: 2;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
}

.sales-total {
	font-size: 1rem;
	color: #21a315;
	font-weight: normal;
	vertical-align: middle;
}

.filter-spacer {
	width: 0px;
	flex: 0 0 auto;
	visibility: hidden;
}

.filters select {
	padding: 5px;
	font-size: 14px;
}

.table-area {
	flex: 1;
	overflow: auto;
	padding: 10px;
	padding-top: 0px
}

 table { 
    width: 100%; 
}

table, th, td {
	border: 1px solid #888;
    border-collapse: collapse;
}

th, td {
	padding: 2px;
	text-align: left;
	word-wrap: break-word;
	white-space: normal;
	font-size: 12px;
}

.button-grid {
	display: grid;
	grid-template-columns: repeat(10, 1fr);
	gap: 10px;
	padding: 15px 10px;
	background-color: #f4f4f4;
	border-top: 1px solid #ccc;
	justify-items: stretch;
	align-items: stretch;
}

	.button-grid button,
	.button-grid select {
		font-size: 18px;
		padding: 10px 0;
		width: 100%;
		height: 44px;
		box-sizing: border-box;
	}

	.button-grid a {
		text-align: center;
		align-self: center;
		padding: 10px 0;
		display: block;
	}

	.row-count {
		margin: 10px 0;
		font-weight: bold;
		text-align: center;
	}

	#xmlTable .sublet-column {
		white-space: nowrap;
		vertical-align: middle;
	}

	#xmlTable thead th {
		position: sticky;
		top: 0;
		background: #121096;
		color: #fff;
		z-index: 2;
		text-align: center;
	}

/* Hide the "No file chosen" text */
	#fileInput {
		color: transparent;
	width: 150px;
}

	#fileInput::-webkit-file-upload-button {
		background-color: #4CAF50;
		color: white;
		padding: 10px 15px;
		border: none;
		cursor: pointer;
		font-size: 14px;
		border-radius: 4px;
	}

	#fileInput::file-selector-button {
		background-color: #4CAF50;
		color: white;
		padding: 10px 15px;
		border: none;
		cursor: pointer;
		font-size: 14px;
		border-radius: 4px;
	}

	#fileInput::-webkit-file-upload-button:hover,
	#fileInput::file-selector-button:hover {
		background-color: #45a049;
	}

	/* Modal message styling */
	.message-modal {
		position: fixed;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		background: white;
		border-radius: 8px;
		padding: 30px;
		max-width: 600px;
		z-index: 10000;
		box-shadow: 0 4px 20px rgba(0,0,0,0.3);
	}

	.message-modal.error {
		border: 3px solid #dc3545;
	}

		.message-modal.warning {
			border: 3px solid #ff8c00;
			max-width: 800px;
		}

	.message-modal h2 {
		margin-top: 0;
	}

	.message-modal h2.error {
		color: #dc3545;
	}

	.message-modal h2.warning {
		color: #ff8c00;
	}

	.message-modal p {
		font-size: 16px;
		line-height: 1.6;
	}

	.message-modal .button-group {
		margin-top: 20px;
		display: flex;
		gap: 10px;
		justify-content: flex-end;
	}

	.message-modal button {
		padding: 10px 20px;
		color: white;
		border: none;
		border-radius: 4px;
		cursor: pointer;
		font-size: 16px;
	}

	.message-modal button.primary {
		background: #007bff;
	}

	.message-modal button.primary:hover {
		background: #0056b3;
	}

	.message-modal button.success {
		background: #28a745;
	}

	.message-modal button.success:hover {
		background: #218838;
	}

	.message-modal button.secondary {
		background: #6c757d;
	}

	.message-modal button.secondary:hover {
		background: #5a6268;
	}

	.message-modal button.cancel {
		background: #6c757d;
	}

	.message-modal button.cancel:hover {
		background: #5a6268;
	}

/* ========================================
   RESPONSIVE STYLES FOR SMALLER SCREENS
   ======================================== */
/* ===== Single source of truth for screens 1300px and under ===== */
@media screen and (max-width: 1300px) {

    /* --- Top filter bar: main select on its own row, then filters + action buttons --- */
    .filters {
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 10px;
    }

    .main-select-center {
        position: static;
        transform: none;
        order: -1;
        flex: 1 1 100%;
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 10px;
        margin-bottom: 5px;
    }

    #viewAllButton {
        position: static;
        transform: none;
        margin-right: 0;
    }

    .filter-group {
        position: static;
        order: 0;
    }

    .action-buttons-right {
        position: absolute;
        top: 48px;          /* sits just below the search, level with the dropdowns */
        right: 20px;
        margin: 0;
        z-index: 4;
    }

    /* --- Header info bar: sales | title | shop share one row --- */
    #headerInfoBar {
        flex-wrap: wrap !important;
        position: static !important; /* let the search anchor to the page, above the Print button */
    }

    #salesContainer {
        flex: 0 0 auto !important;
        order: 0 !important; /* left */
    }

    #titleContainer {
        position: absolute !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        text-align: center !important;
        margin-bottom: 0 !important;
    }

    #shopInfo {
        flex: 0 0 auto !important;
        order: 2 !important; /* right */
        margin-left: auto !important;
    }

    #datePickerContainer {
        order: 0 !important;
    }
}



/* Extra small screens (phones) */
@media screen and (max-width: 600px) {

    .filters {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 8px;
        gap: 8px;
    }

    .collapsible-filters {
        display: flex !important;
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: center;
    }

    .filter-group {
        flex-direction: row;
        flex-wrap: nowrap;
        width: auto;
        gap: 6px;
    }

        .filter-group select {
            width: auto;
            max-width: none;
            flex: none;
        }

    .main-select-center {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 6px;
        width: auto;
    }

    #mainFilterSelect,
    .main-Filter-Select {
        width: auto;
        max-width: none;
    }

    .main-select-center button {
        width: auto;
    }

    .hide-on-mobile {
        display: none !important;
    }

    .table-area {
        padding: 5px;
    }

    th, td {
        padding: 4px 2px;
        font-size: 11px;
    }

    .button-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 5px;
        padding: 10px 5px;
    }

        .button-grid button,
        .button-grid select {
            font-size: 14px;
            height: 38px;
        }
}

/* Very small screens */
@media screen and (max-width: 400px) {
    .button-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    th, td {
        font-size: 10px;
    }
}

/* Tech mode - hide UI elements */
body.tech-mode #filterGroup,
body.tech-mode #filterGroupRight,
body.tech-mode #mainFilterSelect,
body.tech-mode #viewAllButton,
body.tech-mode #refreshButton,
body.tech-mode #mobileFilterToggle,
body.tech-mode #salesContainer,
body.tech-mode #searchContainer,
body.tech-mode #changeShopLink,
body.tech-mode .action-buttons-right {
    display: none !important;
}

body.tech-mode #techRefreshButton {
    display: inline-block !important;
}



/* Smaller screens - hide search, keep date picker */
@media screen and (max-width: 900px) {
    #searchContainer {
        display: none !important;
    }
    
    #shopInfo {
        flex: 0 0 auto !important;
        text-align: right;
    }
}

/* iPhone / small phone screens - hide sales, center title */
@media screen and (max-width: 500px) {
    /* Hide sales totals container entirely */
    #salesContainer {
        display: none !important;
    }
    
    /* Hide date picker on very small screens */
    #datePickerContainer {
        display: none !important;
    }
    
    /* Hide search on very small screens */
    #searchContainer {
        display: none !important;
    }
    
    /* Reorganize the header bar */
    #headerInfoBar {
        flex-wrap: wrap !important;
        justify-content: center !important;
        padding: 10px !important;
        gap: 8px !important;
    }
    
    /* Center the title and make it full width */
    #titleContainer {
        position: static !important;
        transform: none !important;
        flex: 1 1 100% !important;
        order: -1 !important;
        text-align: center !important;
    }
    
    #pageTitle {
        font-size: 18px !important;
    }
    
    /* Center the shop info */
    #shopInfo {
        flex: 1 1 100% !important;
        text-align: center !important;
    }
    
    #companyShopLine,
    #fileDateDisplay {
        white-space: normal !important;
    }
   
}

/* Phone toolbar: Filters, More and Search on one row (phones only) */
#phoneToolbar {
    display: none;
}

#searchKeyboardToggle {
    display: none;
}

@media screen and (max-width: 600px) {
    #filterGroup {
        display: none !important;
    }

    #phoneToolbar {
        display: flex;
        flex: 1 1 100%;
        align-items: center;
        gap: 6px;
    }

        #phoneToolbar select {
            width: auto;
            max-width: 120px;
            padding: 5px;
            font-size: 14px;
        }

        #phoneToolbar #searchContainer {
            display: flex !important;
            flex: 1 1 auto;
            width: auto !important;
            min-width: 0;
        }

        #phoneToolbar #quickSearch {
            font-size: 16px !important; /* 16px or more stops iPhone zooming in on tap */
        }

        #phoneToolbar #phoneVideosButton {
            flex: none;
            padding: 6px 8px;
            font-size: 12px;
            font-weight: 600;
            color: #23456a;
            background: #fff;
            border: 1px solid #ccc;
            border-radius: 4px;
        }

        #phoneToolbar #searchKeyboardToggle {
            display: block;
            flex: none;
            margin-right: 4px;
            padding: 6px;
            font-size: 12px;
            font-weight: 600;
            color: #23456a;
            background: #fff;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
}

body.tech-mode #phoneToolbar {
    display: none !important;
}
