﻿/* GLOBAL RESET & BOX SIZING */
* {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

img,
video {
    max-width: 100%;
    height: auto;
}

/* LOGIN PAGE */
.login-body {
    background: #f5f7fb;
    font-family: 'Arial', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    /* Changed from height to min-height */
    padding: 20px;
}

/* Login Card */
.login-card {
    width: 100%;
    max-width: 380px;
    /* Controls width on desktop */
    background: #ffffff;
    padding: 35px 30px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

/* Header */
.login-header {
    text-align: center;
    margin-bottom: 25px;
}

.login-icon {
    width: 60px;
    margin-bottom: 10px;
}

.login-header h2 {
    font-size: 26px;
    font-weight: bold;
    margin: 0;
}

.login-header h3 {
    font-size: 20px;
    margin: 6px 0 20px;
    color: #333;
}

/* Labels */
label {
    font-size: 15px;
    font-weight: bold;
    color: #444;
}

/* Form Inputs */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"] {
    width: 100%;
    padding: 12px;
    margin: 6px 0 14px;
    border-radius: 8px;
    border: 1px solid #ccc;
    background: #fafafa;
    font-size: 15px;
}

/* Show password */
.password-box {
    position: relative;
}

.show-btn {
    position: absolute;
    right: 10px;
    top: 14px;
    color: #1e74ff;
    cursor: pointer;
    font-size: 14px;
}

/* Remember me */
.remember-box {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.remember-box label {
    margin-left: 5px;
    font-weight: normal;
}

/* Login Button */
.login-btn {
    width: 100%;
    padding: 12px;
    background: #1e74ff;
    border: none;
    color: #fff;
    font-size: 17px;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 5px;
}

.login-btn:hover {
    background: #0d5eea;
}

/* ---------------------------- */
/* RESPONSIVE DESIGN */
/* ---------------------------- */

/* For phones < 400px */
@media (max-width: 400px) {

    .login-card {
        padding: 25px 20px;
    }

    .login-header h2 {
        font-size: 22px;
    }

    .login-header h3 {
        font-size: 17px;
    }

    .login-btn {
        font-size: 16px;
        padding: 10px;
    }

    input[type="text"],
    input[type="password"] {
        padding: 10px;
        font-size: 14px;
    }
}

/* For very small phones < 330px */
@media (max-width: 330px) {

    .login-card {
        padding: 20px 15px;
        border-radius: 10px;
    }

    label {
        font-size: 14px;
    }

    .login-header h2 {
        font-size: 20px;
    }

    .login-header h3 {
        font-size: 16px;
    }

    .login-icon {
        width: 50px;
    }
}



/* DASHBOARD PAGE */

.dashboard-body {
    background: #f5f7fb;
    padding: 20px;
    font-family: Arial, sans-serif;
}

.dashboard-container {
    max-width: 800px;
    margin: auto;
    text-align: center;
    width: 100%;
    /* Ensure it doesn't overflow */
}

.dash-icon {
    width: 80px;
    margin-top: 20px;
}

.dash-title {
    font-size: 32px;
    color: #333;
    margin-top: 10px;
    margin-bottom: 20px;
    font-weight: bold;
    word-wrap: break-word;
    /* Prevent long titles from breaking layout */
}

.dash-line {
    border: none;
    border-top: 2px solid #ddd;
    margin: 20px 0;
}

.welcome-box {
    background: #fafafa;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
}

.welcome-box h2 {
    margin-bottom: 15px;
    color: #333;
}

.welcome-box p {
    margin: 5px 0;
    font-size: 16px;
    color: #222;
}

.action-title {
    margin-top: 15px;
    margin-bottom: 15px;
    color: #444;
    font-size: 24px;
    font-weight: bold;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
}

.dash-btn {
    display: inline-block;
    padding: 12px 25px;
    background: #057dff;
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-size: 16px;
    font-weight: bold;
    min-width: 180px;
    text-align: center;
    transition: 0.2s;
}

.dash-btn:hover {
    background: #0069d9;
}

.logout-btn {
    display: block;
    width: 200px;
    margin: 30px auto;
    padding: 12px;
    background: #d64545;
    color: #fff;
    text-align: center;
    font-size: 18px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
}

.logout-btn:hover {
    background: #b73838;
}

/* Responsive (for mobile) */
@media (max-width: 600px) {
    .dash-btn {
        min-width: 100%;
        font-size: 16px;
        padding: 12px;
    }

    .welcome-box {
        margin: 15px 0;
        /* Removed horizontal margin to prevent overflow */
        padding: 15px;
    }

    .dashboard-body {
        padding: 10px;
        /* Reduce padding on mobile */
    }
}

/* Danger (red) button */
.danger-btn {
    display: inline-block;
    padding: 12px 25px;
    background: #ff3b3b;
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    min-width: 180px;
    text-align: center;
    transition: 0.2s;
}

.danger-btn:hover {
    background: #d32f2f;
}


/* =========================
   ORDER ENTRY (corrected)
   ========================= */

.order-body {
    background: #f5f7fb;
    padding: 20px;
    font-family: Arial, sans-serif;
}

/* Main container */
.order-entry-box {
    max-width: 850px;
    width: 100%;
    margin: 0 auto;
    background: #ffffff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Title */
.order-entry-title {
    text-align: center;
    font-size: 26px;
    font-weight: bold;
    color: #333;
    margin-bottom: 20px;
}

/* Labels & selects */
.order-entry-box label {
    font-weight: bold;
    color: #444;
    margin-bottom: 6px;
    display: block;
}

.order-entry-box select {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fafafa;
    margin-bottom: 15px;
}

/* ================
   COMPACT ROW
   ================ */

/* ------------------------------- */
/* DESKTOP: one clean line         */
/* ------------------------------- */

.compact-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    /* Changed to 1fr for flexibility */
    gap: 15px;
    /* Reduced gap */
    margin-bottom: 20px;
}

/* Box style */
.compact-small label {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 4px;
    display: block;
}

.compact-small input {
    width: 100%;
    padding: 7px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    background: #fafafa;
}


/* ------------------------------- */
/* MOBILE VERSION (two rows only)  */
/* ------------------------------- */
@media (max-width: 768px) {
    .compact-row {
        grid-template-columns: repeat(3, 1fr);
        /* 3 columns for tablet/large phone */
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .compact-row {
        grid-template-columns: repeat(2, 1fr);
        /* 2 columns for small phone */
        gap: 10px;
    }

    .order-body {
        padding: 10px;
    }

    .order-entry-box {
        padding: 15px;
    }
}


/* =====================================
   ORDER ENTRY FORM ROWS (NEW LAYOUT)
   ===================================== */

/* Generic order row container */
.order-row {
    display: grid;
    gap: 12px;
    margin-bottom: 15px;
}

/* 4-column row (UOM, Packing, Qty, Free) */
.order-row.row-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* 3-column row (Rate, Disc%, D_Amt) and (MRP, GST, Batch) */
.order-row.row-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* Individual field box */
.field-box {
    display: flex;
    flex-direction: column;
}

.field-box label {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 4px;
    color: #444;
}

.field-box input,
.field-box select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    background: #fafafa;
}

.field-box input[readonly] {
    background: #e9ecef;
    cursor: not-allowed;
}

/* Checkbox styling for Free field */
.field-box input[type="checkbox"] {
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    margin-top: 8px;
    transform: scale(1.3);
    cursor: pointer;
}

/* Order Actions (Buttons Container) */
.order-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.order-actions .order-btn {
    flex: 1;
    margin-top: 0;
}

/* Mobile Responsive for Order Rows */
@media (max-width: 768px) {

    /* On tablets, keep 3 columns for row-4 */
    .order-row.row-4 {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Keep 3 columns for row-3 */
    .order-row.row-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {

    /* On mobile, use proportional widths based on field content */
    .order-row.row-4 {
        grid-template-columns: 3fr 1.5fr 2.5fr 1fr;
        gap: 6px;
    }

    /* On mobile, use proportional widths for row-3 fields */
    .order-row.row-3 {
        grid-template-columns: 2.5fr 1.5fr 2fr;
        gap: 6px;
    }

    .field-box input,
    .field-box select {
        padding: 4px 6px;
        font-size: 12px;
        height: 40px;
    }

    .field-box label {
        font-size: 11px;
        margin-bottom: 2px;
    }

    /* Keep buttons side-by-side on mobile */
    .order-actions {
        flex-direction: row;
        gap: 6px;
    }

    .order-actions .order-btn {
        flex: 1;
        padding: 10px;
        font-size: 14px;
    }
}


/* Buttons */
.order-btn {
    width: 100%;
    padding: 14px;
    background: #057dff;
    color: #fff;
    border: none;
    font-size: 17px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 10px;
    transition: 0.2s;
}

.order-btn:hover {
    background: #0069d9;
}

@media (max-width: 768px) {
    .order-btn {
        width: 48%;
        padding: 10px;
        font-size: 14px;
        margin-top: 10px;
        margin-right: 2%;
        display: inline-block;
        vertical-align: top;
    }

    .order-btn:last-of-type {
        margin-right: 0;
    }
}

/* Saved Items Table */
.saved-title {
    text-align: center;
    font-size: 22px;
    margin-top: 25px;
    color: #333;
}

.order-table {
    width: 100%;
    margin-top: 10px;
    border-collapse: collapse;
}

.order-table th {
    background: #057dff;
    color: white;
    padding: 10px;
    text-align: center;
    font-size: 15px;
    white-space: nowrap;
    /* Prevent header wrapping if possible */
}

.order-table td {
    padding: 10px;
    border: 1px solid #ccc;
    text-align: center;
}

.order-table button {
    padding: 6px 10px;
    background: #ff4545;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.order-table button:hover {
    background: #d63232;
}



/* =========================
   ORDER DETAILS PAGE
   ========================= */
.order-details {
    background: #fff;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

/* Table Styles (Enhanced) */
.order-table-full {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    min-width: 600px;
    /* Ensure table has min width to trigger scroll */
}

.order-table-full th {
    background: #0078d7;
    color: white;
    padding: 12px;
    text-align: left;
}

.order-table-full td {
    padding: 10px;
    border-bottom: 1px solid #ddd;
}

/* ----------------------------------------------------
   MOBILE CARDS FOR TABLES (DEACTIVATED TO KEEP TABLE VIEW)
   ---------------------------------------------------- */
/*
@media (max-width: 768px) {
    .order-table-full thead {
        display: none;
    }

    .order-table-full, 
    .order-table-full tbody, 
    .order-table-full tr, 
    .order-table-full td {
        display: block;
        width: 100%;
    }

    .order-table-full tr {
        margin-bottom: 15px;
        background: #fff;
        border: 1px solid #e1e1e1;
        border-radius: 8px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
        padding: 10px;
    }

    .order-table-full td {
        text-align: right;
        padding: 8px 5px;
        position: relative;
        padding-left: 40%;
        border-bottom: 1px solid #eee;
    }

    .order-table-full td:last-child {
        border-bottom: none;
        text-align: center;
        padding-left: 0;
        margin-top: 5px;
    }

    .order-table-full td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 35%;
        padding-left: 10px;
        font-weight: bold;
        text-align: left;
        color: #555;
    }
}
*/

.order-table-full tr:hover {
    background: #f1f9ff;
}

/* Action Buttons */
.btn {
    padding: 6px 10px;
    border-radius: 5px;
    color: white;
    cursor: pointer;
    margin: 2px;
    font-size: 13px;
    border: none;
    text-decoration: none;
    display: inline-block;
}

.view {
    background: #28a745;
}

.edit {
    background: #17a2b8;
}

.download {
    background: #0078d7;
}

.delete {
    background: #dc3545;
}

.btn:hover {
    opacity: 0.9;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 10px;
    /* Add padding for small screens */
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    width: 100%;
    max-width: 700px;
    position: relative;
    max-height: 90vh;
    /* Prevent modal from being taller than screen */
    overflow-y: auto;
    /* Enable scrolling within modal */
}

.close {
    float: right;
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    color: #aaa;
}

.close:hover {
    color: #000;
}

/* ---------------------------- */
/* MOBILE RESPONSIVENESS UPDATES */
/* ---------------------------- */

/* Table Scrolling for Mobile */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    /* Enable horizontal scrolling */
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
    margin-bottom: 15px;
}

@media (max-width: 768px) {
    .order-entry-box {
        padding: 15px;
    }

    /* Compact Row on very small screens */
    .compact-small input {
        padding: 8px 5px;
        /* Smaller padding */
        height: 30px;
    }
}

/* Select2 Mobile Fixes */
.select2-container {
    width: 100% !important;
    margin-bottom: 15px;
}

.select2-selection {
    height: 42px !important;
    padding: 6px !important;
    border: 1px solid #ccc !important;
    border-radius: 8px !important;
    background: #fafafa !important;
}

/* FORCED DESKTOP TABLE VIEW ON ALL SCREENS */
@media (max-width: 1024px) {

    .order-table-full,
    .order-table-full thead,
    .order-table-full tbody,
    .order-table-full tr,
    .order-table-full td {
        display: revert !important;
        width: auto !important;
    }

    .order-table-full thead {
        display: table-header-group !important;
    }

    .order-table-full tr {
        display: table-row !important;
        margin-bottom: 0 !important;
        background: transparent !important;
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        padding: 0 !important;
    }

    .order-table-full td {
        display: table-cell !important;
        text-align: left !important;
        padding: 10px !important;
        position: static !important;
        border-bottom: 1px solid #ddd !important;
        padding-left: 10px !important;
        width: auto !important;
    }

    .order-table-full td::before {
        display: none !important;
        content: "" !important;
    }

    .table-responsive {
        overflow-x: auto !important;
        display: block !important;
    }
}