@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #10B981;
    --secondary-hover: #059669;
    --accent: #F59E0B;
    --danger: #EF4444;
    --dark: #1F2937;
    --text-main: #374151;
    --text-muted: #6B7280;
    --bg-main: #F3F4F6;
    --surface: rgba(255, 255, 255, 0.85);
    --border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    overscroll-behavior-y: none !important;
    overscroll-behavior-x: none !important;
}

body {
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    background-attachment: scroll;
    margin: 0;
    padding: 20px;
    color: var(--text-main);
    min-height: 100vh;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Glassmorphism Container */
.container {
    max-width: 1150px;
    margin: auto;
    background: #ffffff;
    padding: 35px;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--glass-shadow);
}

h2, h3 {
    color: var(--dark);
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: -0.5px;
}

h2#pageTitle {
    background: linear-gradient(135deg, var(--primary) 0%, #a855f7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 2.2rem;
    text-align: center;
    margin-bottom: 30px;
}

/* ---------------------------------------------------- */
/* PREMIUM BUTTONS */
/* ---------------------------------------------------- */
button, .btn, .topbtn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    text-decoration: none;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    z-index: 1;
}

button::before, .btn::before, .topbtn::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255,255,255,0.15);
    z-index: -1;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

button:hover::before, .btn:hover::before, .topbtn:hover::before {
    transform: scaleX(1);
}

button:hover, .btn:hover, .topbtn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
}

button:active, .btn:active, .topbtn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Button Colors */
.btn-dark, .topbtn:not(.pendingbtn):not(.readybtn):not(.deliveredbtn) { background: linear-gradient(135deg, var(--primary), #3b82f6); color: white; }
.deliveredbtn, .btn-success, .add-btn, .wa-btn { background: linear-gradient(135deg, var(--secondary), #10b981); color: white; }
.readybtn { background: linear-gradient(135deg, var(--accent), #f59e0b); color: white; }
.pendingbtn, .remove-btn, .close-btn-styled { background: linear-gradient(135deg, var(--danger), #ef4444); color: white; }

/* ---------------------------------------------------- */
/* INPUTS & SELECTS */
/* ---------------------------------------------------- */
input, select, textarea {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: rgba(255,255,255,0.9);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 10px;
    box-sizing: border-box;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-main);
    transition: var(--transition);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
    background: #fff;
    transform: translateY(-1px);
}

/* File Input Styling */
input[type="file"] {
    padding: 10px;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    cursor: pointer;
}
input[type="file"]:hover {
    border-color: var(--primary);
    background: #f1f5f9;
}

textarea { min-height: 80px; resize: vertical; }

/* ---------------------------------------------------- */
/* LAYOUTS & COMPONENTS */
/* ---------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.topbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 30px; justify-content: center; }

/* Glass Item Card */
.item-card {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    transition: var(--transition);
}
.item-card:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.06);
    transform: translateY(-2px);
}

.item-head { display: flex; gap: 15px; align-items: center; margin-bottom: 20px; }
.item-head select { margin-bottom: 0; flex: 2; }
.item-head .item-qty { flex: 1; margin-bottom: 0; }
.remove-btn { width: auto; padding: 12px 20px; flex: 1; }

.measure-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 15px; }
.measure-field { display: flex; flex-direction: column; align-items: center; }
.measure-field label { font-weight: 600; color: var(--text-muted); margin-bottom: 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.measure-field input { font-size: 18px; font-weight: 700; padding: 10px 5px; text-align: center; color: var(--primary); border-radius: 8px; }
/* Fixed tailoring dropdowns: keep the full selected option visible. */
.measure-field-select { grid-column: span 2; align-items: flex-start; min-width: 0; }
.measure-field select.measure-select {
    width: max-content;
    min-width: 190px;
    max-width: 100%;
    margin-bottom: 0;
    padding: 10px 28px 10px 10px;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    text-align: left;
}
.measure-field select.measure-lapel-select { min-width: 155px; }
/* Keep fixed Style and Lapel dropdowns wide enough for their full selected labels. */
.measure-field:has(select) { grid-column: span 2; align-items: stretch; min-width: 0; }
.measure-field select { width: 100%; min-width: 180px; max-width: 100%; box-sizing: border-box; white-space: nowrap; font-size: 15px; padding: 10px 8px; margin-bottom: 0; text-overflow: clip; }

.mob-cust-list { display: none; }

/* Tables Design */
table { width: 100%; border-collapse: separate; border-spacing: 0 8px; margin-top: 15px; }
th, td { padding: 15px; text-align: left; font-size: 14px; }
th { background: rgba(79, 70, 229, 0.1); color: var(--primary); font-weight: 600; text-transform: uppercase; font-size: 12px; letter-spacing: 1px; border-radius: 8px; }
td { background: white; border-top: 1px solid #f1f5f9; border-bottom: 1px solid #f1f5f9; }
td:first-child { border-left: 1px solid #f1f5f9; border-radius: 10px 0 0 10px; }
td:last-child { border-right: 1px solid #f1f5f9; border-radius: 0 10px 10px 0; }
tr { transition: var(--transition); }
tr:hover td { background: #f8fafc; transform: scale(1.01); }

/* Popups & Modals (Glassmorphism) */
.modal, .popup-overlay { display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(8px); align-items: center; justify-content: center; padding: 20px; }
.modal-content, .popup-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 35px;
    border-radius: 24px;
    width: 100%;
    max-width: 600px;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-height: 90vh;
    overflow-y: auto;
    animation: fadeInUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Helpers */
.suggest-box { background: rgba(255,255,255,0.95); backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: 12px; margin-top: -8px; margin-bottom: 15px; display: none; max-height: 200px; overflow: auto; box-shadow: 0 10px 25px rgba(0,0,0,0.1); position: absolute; width: calc(100% - 40px); z-index: 10; }
.suggest-item { padding: 12px 15px; cursor: pointer; border-bottom: 1px solid #f1f5f9; font-weight: 500; font-size: 14px; transition: var(--transition); }
.suggest-item:hover { background: var(--primary); color: white; padding-left: 20px; }
.edit-note { display: none; background: rgba(245, 158, 11, 0.1); color: #b45309; padding: 15px; border-radius: 10px; margin-bottom: 20px; font-weight: 600; font-size: 14px; border: 1px solid rgba(245, 158, 11, 0.2); }
#msg { margin-top: 20px; padding: 15px; display: none; border-radius: 10px; font-weight: 600; font-size: 14px; text-align: center; animation: fadeInUp 0.3s ease; }
.success { background: rgba(16, 185, 129, 0.1); color: #047857; border: 1px solid rgba(16, 185, 129, 0.2); }
.error { background: rgba(239, 68, 68, 0.1); color: #b91c1c; border: 1px solid rgba(239, 68, 68, 0.2); }
.info { background: rgba(59, 130, 246, 0.1); color: #1d4ed8; border: 1px solid rgba(59, 130, 246, 0.2); }
.image-preview { display: none; max-width: 200px; border-radius: 12px; margin-bottom: 15px; box-shadow: 0 8px 16px rgba(0,0,0,0.1); border: 3px solid white; }

@media(max-width: 992px){
    .grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .measure-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
}

@media(max-width: 768px){
    body { padding: 5px; }
    .container { padding: 10px; border-radius: 12px; margin: 0; box-shadow: none; border-left: none; border-right: none; }
    
    h2#pageTitle { font-size: 1.4rem; margin-bottom: 12px; margin-top: 5px; }
    h3 { font-size: 1.1rem; margin-bottom: 10px; }
    
    .topbar { 
        display: flex; flex-wrap: nowrap; overflow-x: auto; 
        gap: 8px; padding-bottom: 8px; margin-bottom: 15px;
        justify-content: flex-start; -webkit-overflow-scrolling: touch; 
    }
    .topbtn { flex: 0 0 auto; padding: 8px 14px; font-size: 13px; border-radius: 20px; white-space: nowrap; margin-bottom: 0; }
    
    /* Hide scrollbar for topbar */
    .topbar::-webkit-scrollbar { display: none; }
    .topbar { -ms-overflow-style: none; scrollbar-width: none; }
    
    .grid, .controls { grid-template-columns: 1fr; gap: 10px; margin-bottom: 12px; }
    
    .item-head { flex-direction: column; align-items: stretch; gap: 8px; margin-bottom: 10px; }
    .item-head select, .item-head .item-qty { width: 100%; }
    .remove-btn { width: 100%; padding: 10px; }
    
    .measure-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .measure-field label { font-size: 10px; margin-bottom: 3px; }
    .measure-field input { font-size: 15px; padding: 6px; }
    .measure-field-select { grid-column: span 2; }
    .measure-field select.measure-select { min-width: 0; width: 100%; max-width: 100%; font-size: 14px; padding: 8px 24px 8px 8px; }
    .measure-field select { font-size: 14px; padding: 8px 6px; min-width: 0; }
    
    table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
    th, td { padding: 8px; font-size: 13px; }
    
    .desk-table { display: none !important; }
    .mob-cust-list, .mobile-list { display: block !important; }
    
    .modal-content, .popup-content { padding: 15px; width: 95%; max-width: none; border-radius: 12px; margin: auto; }
    
    .action-buttons, .status-buttons, .popup-buttons { display: flex; flex-direction: column; gap: 8px; }
    .popup-buttons button { width: 100% !important; margin: 0 !important; }
}

@media(max-width: 480px){
    h2#pageTitle { font-size: 1.3rem; }
    .measure-grid { grid-template-columns: repeat(2, 1fr); }
    .measure-field input { font-size: 14px; }
    .item-card { padding: 12px; margin-bottom: 10px; }
}