:root { --panel-bg: #f4f4f9; --border: #ddd; }
body { margin: 0; font-family: sans-serif; display: flex; height: 100vh; }

/* Panels */
.left-panel { width: 30%; background: var(--panel-bg); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; }
.right-panel { width: 70%; background: #525659; overflow: auto; padding: 40px; display: flex; justify-content: center; }

.ctrl-section { padding: 15px; border-bottom: 1px solid var(--border); }
input, select, textarea { width: 100%; margin-bottom: 10px; padding: 8px; box-sizing: border-box; }

/* The Virtual Paper Container */
#paper {
    background: white;
    width: 210mm; 
    height: 297mm;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    overflow: hidden; 
    z-index: 1; /* Creates a new stacking context */
}

/* Pseudo-element for the Transparent Background Image */
#paper::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* FIXED TYPO: changed 'asstet' to 'assets' and added ../ if CSS is in a subfolder */
    background-image: url("../templates/invoice-template.png"); 
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.2; 
    z-index: -1; /* Pushes the image behind the text fields */
    pointer-events: none; 
}

/* Draggable Fields */
.field { 
    position: absolute; 
    cursor: move; 
    border: 1px dashed transparent; 
    padding: 2px; 
    z-index: 10; /* Ensures text is always on top */
}

.field:hover { border: 1px dashed blue; }
.locked { cursor: default !important; }

/* Table Styling */
#p-items {
    width: 710px !important; /* Force exact width */
    min-width: 710px; 
    cursor: move;
    overflow: visible; /* Ensure content doesn't get cut off */
}

#target-table {
    width: 100% !important;
    table-layout: fixed !important; 
    border-collapse: collapse;
    background-color: transparent;
}



#target-table th:nth-child(1), #target-table td:nth-child(1) { width: 7%;text-align: center; vertical-align: middle; }
#target-table th:nth-child(2), #target-table td:nth-child(2) { width: 31%;padding-left: 3px;text-align: left; }
#target-table th:nth-child(3), #target-table td:nth-child(3) { width: 28%; }
#target-table th:nth-child(4), #target-table td:nth-child(4) { width: 10%;text-align: center; vertical-align: middle; }
#target-table th:nth-child(5), #target-table td:nth-child(5) { width: 12%; }
#target-table th:nth-child(6), #target-table td:nth-child(6) { width: 12%; }

#target-table th:nth-child(7), #target-table td:nth-child(7) { 
    width: 10px; 
    text-align: center;
}

.btn-delete {
    color: #ff4d4d;
    cursor: pointer;
    font-weight: bold;
    font-size: 18px;
    border: none;
    background: none;
    padding: 0;
}

.btn-delete:hover {
    color: #cc0000;
}


#target-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 2px 5px;
}
#target-table thead {
    visibility: hidden;
}




/* Print Logic */
@media print {
    /* Add @page rule to control page margins and remove headers/footers */
    @page {
        margin: 0 !important;
        size: auto; /* Use 'auto' or specify custom size like: size: 8.5in 11in; */
        marks: none; /* Removes crop marks */
    }

    /* You can also target specific page types */
    @page :first {
        margin: 0 !important;
    }
    
    @page :left {
        margin: 0 !important;
    }
    
    @page :right {
        margin: 0 !important;
        
        
        
    }

    /* Your existing styles with minor improvements */
    html, body {
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact; /* Standard property */
        width: 100% !important;
    }

    .left-panel, .ctrl-section, button, .no-print { 
        display: none !important; 
        visibility: hidden !important;
    }

    .right-panel { 
        padding: 0 !important; 
        margin: 0 !important; 
        background: none !important; 
        display: block !important;
        overflow: visible !important;
        width: 100% !important;
        height: auto !important;
        min-height: 100vh !important; /* Ensure it fills the page */
        float: none !important;
    }

    #paper { 
        box-shadow: none !important; 
        margin: 0 auto !important; 
        border: none !important; 
        left: 0 !important;
        top: 0 !important;
        position: relative !important;
        overflow: hidden !important;
        width: 100% !important;
        page-break-inside: avoid; /* Prevents page break inside paper */
        page-break-after: avoid; /* Prevents page break after paper */
    }

    #paper::before { 
        display: none !important; 
        content: none !important;
    }
    
    /* Additional useful print styles */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    
    a[href]:after {
        content: none !important; /* Remove URL after links */
    }
    
    /* Force backgrounds to print */
    .right-panel, #paper, .print-bg {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        background-color: white !important;
        background-image: none !important;
    }
    
    

    
    .user-profile-section {
        display: none !important;
    }
    
   
}



#search_results {
    position: absolute;
    z-index: 1000;
    width: 250px; /* Match your input width */
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    border-radius: 4px;
    background: white;
}

#search_results div:hover {
    background-color: #f0f0f0;
    color: #007bff;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    display: none; /* Hidden by default */
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.search-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.4;
}

.search-item:hover {
    background-color: #f8f9fa;
}

.search-item strong {
    color: #007bff;
    display: block;
}

.search-item small {
    color: #666;
}


#visibility-toggles {
    width: 100%;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;              
    white-space: nowrap;      
    font-size: 14px;
    margin-bottom: 6px;
}

.toggle-text {
    flex-grow: 1;      /* 🟢 Take available space */
    flex-shrink: 0;    /* 🟢 Don't shrink to 0 */
    margin-right: 10px; /* Optional spacing from checkbox */
}

.toggle-row input[type="checkbox"] {
    flex-shrink: 0;
    transform: scale(1.1);
    margin: 0;
}



/* User Profile Section in Sidebar */
.user-profile-section {
    padding: 12px 15px;
    background: #ffffff; /* Clean white background */
    border-bottom: 2px solid #007bff; /* Blue accent line */
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.user-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #333;
    font-size: 14px;
}

.user-icon {
    font-size: 16px;
    background: #e9ecef;
    padding: 5px;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#logged_user_name {
    font-weight: 600;
    color: #2c3e50;
}

.btn-logout-small {
    text-decoration: none;
    font-size: 11px;
    font-weight: bold;
    color: #dc3545; /* Red logout color */
    padding: 4px 10px;
    border: 1px solid #dc3545;
    border-radius: 3px;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.btn-logout-small:hover {
    background: #dc3545;
    color: #ffffff;
}

/* Default state (Unlocked) */
#lock-btn {
    background-color: #28a745; /* Green */
    color: white;
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

/* Active state (Locked) */
#lock-btn.locked {
    background-color: #dc3545; /* Red */
}


/* Class to turn the button red when active */
 .btn-locked-active {
    background-color: #dc3545 !important; /* Red (Locked) */
}

button[onclick="toggleLock()"] {
    background-color: #28a745; /* Default Green (Unlocked) */
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-print {
    background-color: #007bff; /* Primary Blue */
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Hover State */
.btn-print:hover {
    background-color: #0056b3; /* Darker Blue */
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transform: translateY(-1px);
}

/* Active (Pressed) State - Makes it feel like a toggle */
.btn-print:active {
    background-color: #004085;
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}



