/* static/style.css */

/* --- Global Resets & Base Styles --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Cleaner font */
    line-height: 1.6;
    background-color: #f8f9fa; /* Lighter grey background */
    color: #343A40; /* Darker grey for text */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    width: 90%;
    max-width: 1200px; /* Max width for content */
    margin: 0 auto;
    padding: 0 15px;
}

h1, h2, h3, h4, h5, h6 {
    color: #212529; /* Darker heading color */
    margin-bottom: 0.75em;
    font-weight: 500; /* Slightly bolder headings */
}
h1 { font-size: 2.2em; }
h2 { font-size: 1.8em; }
h3 { font-size: 1.5em; }
h4 { font-size: 1.25em; }


a {
    color: #e16506; /* User's primary orange */
    text-decoration: none;
}
a:hover {
    color: #c85a05; /* Darker orange on hover */
    text-decoration: underline;
}

hr {
    border: 0;
    height: 1px;
    background-color: #dee2e6; /* Light grey for hr */
    margin: 1.5em 0;
}

img {
    max-width: 100%;
    height: auto;
    display: block; /* Removes extra space below images */
}

/* --- Navigation Bar --- */
nav.navbar { /* Added .navbar class for more specific styling if needed */
    background-color: #e16506; /* User's primary orange */
    color: white;
    padding: 0.8em 0; /* Adjusted padding */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
nav.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
nav.navbar .navbar-brand {
    font-size: 1.6em;
    color: white;
    font-weight: bold;
    text-decoration: none;
}
nav.navbar .nav-links a {
    color: white;
    margin-left: 1.5em;
    text-decoration: none;
    font-size: 1em;
    transition: opacity 0.2s ease-in-out;
}
nav.navbar .nav-links a:hover {
    opacity: 0.8;
    text-decoration: none;
}
nav.navbar .nav-user-info {
    color: white;
    margin-right: 1.5em;
}


/* --- Main Content Area --- */
main.container {
    padding-top: 2em;
    padding-bottom: 2em;
    flex-grow: 1; /* Allows main to take up available space */
}

/* --- Footer --- */
footer.footer { /* Added .footer class */
    text-align: center;
    padding: 1.5em 0;
    margin-top: auto; /* Pushes footer to bottom */
    background-color: #e16506; /* User's primary orange */
    color: white;
    font-size: 0.9em;
}
footer.footer p { margin: 0; }


/* --- Cards for grouping content --- */
.card {
    background-color: #FFFFFF;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px 25px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card-header {
    margin: -20px -25px 20px -25px; /* Extend to card edges */
    padding: 15px 25px;
    border-bottom: 1px solid #dee2e6;
    background-color: #f8f9fa; /* Light background for card header */
    border-top-left-radius: 8px; /* Match card radius */
    border-top-right-radius: 8px;
}
.card-header h2, .card-header h3, .card-header h4 {
    margin-bottom: 0;
}

/* --- Forms --- */
.form-group { /* Replaces 'form div' for more specific targeting */
    margin-bottom: 1.25em;
}
.form-group label {
    display: block;
    margin-bottom: 0.5em;
    font-weight: 500; /* Bolder labels */
    color: #495057;
}
.form-control { /* Replaces 'form input[type=...], form textarea' */
    display: block;
    width: 100%;
    padding: 0.65em 0.75em;
    font-size: 1em;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: 0.35rem; /* Softer radius */
    box-sizing: border-box;
    transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out;
}
.form-control:focus {
    border-color: #f08a44; /* Lighter shade of user's orange */
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(225, 101, 6, 0.25); /* Focus glow with user's orange */
}
textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

/* For two-column header layout */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px; 
    margin-bottom: 0; /* Handled by form-group inside */
}
.form-row .form-group {
    flex: 1; 
    min-width: calc(50% - 10px); /* Tries for two per row, accounting for gap */
    margin-bottom: 1.25em; 
}
.form-row .form-group.full-width { /* If a field needs to span full-width within a row context */
    min-width: 100%;
    flex-basis: 100%;
}


.info-text, .form-info-text { /* Merged and renamed for consistency */
    font-size: 0.875em; /* Slightly smaller */
    color: #6c757d; /* Softer grey */
    margin-top: 0.4em;
}

/* --- Buttons --- */
.btn { /* Base button style */
    display: inline-block;
    font-weight: 500;
    color: #fff;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: #6c757d; /* Default grey */
    border: 1px solid transparent;
    padding: 0.65em 1.2em;
    font-size: 1em;
    line-height: 1.5;
    border-radius: 0.35rem;
    text-decoration: none;
    transition: all 0.15s ease-in-out;
}
.btn-primary {
    background-color: #e16506; /* User's primary orange */
    border-color: #e16506;
}
.btn-primary:hover {
    background-color: #c85a05; /* Darker orange */
    border-color: #bd5404;
    color: #fff;
}
.btn-primary:focus {
    box-shadow: 0 0 0 0.2rem rgba(225, 101, 6, 0.5);
}
.btn-secondary {
    background-color: #6c757d; /* Medium Grey */
    border-color: #6c757d;
}
.btn-secondary:hover {
    background-color: #5a6268;
    border-color: #545b62;
    color: #fff;
}
/* For form button, if not using .btn classes directly */
form button[type="submit"] { /* Keep user's original if preferred, or switch to .btn */
    background-color: #e16506;
    color: white;
    padding: 0.7em 1.5em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.15s ease-in-out;
}
form button[type="submit"]:hover {
    background-color: #c85a05; /* Darker orange */
}
/* --- Status Indicator Styles --- */
.status-badge {
    padding: 0.3em 0.6em;
    border-radius: 0.25rem; /* Or your preferred border-radius */
    font-size: 0.85em;
    font-weight: 500;
    text-transform: uppercase;
    color: white;
    display: inline-block;
    min-width: 90px; /* Adjust as needed for consistent width */
    text-align: center;
    line-height: 1.4; /* Adjust for better vertical centering of text */
}

.status-completed {
    background-color: #28a745; /* Bootstrap Green */
    color: white;
}

.status-pending {
    background-color: #ffc107; /* Bootstrap Yellow */
    color: #212529; /* Dark text for better contrast */
}

.status-ongoing {
    background-color: #fd7e14; /* Bootstrap Orange */
    color: white;
}

/* --- Flash Messages --- */
.flashes {
    list-style-type: none;
    padding: 0;
    margin-bottom: 1.5em;
}
.flashes li {
    padding: 0.85em 1.25em;
    margin-bottom: 0.75em;
    border: 1px solid transparent;
    border-radius: 0.35rem; /* Consistent radius */
    font-size: 0.95em;
}
.flashes .success { background-color: #d4edda; color: #155724; border-color: #c3e6cb; }
.flashes .danger  { background-color: #f8d7da; color: #721c24; border-color: #f5c6cb; }
.flashes .warning { background-color: #fff3cd; color: #856404; border-color: #ffeeba; }
.flashes .info    { background-color: #d1ecf1; color: #0c5460; border-color: #bee5eb; }

/* --- Tables --- */
.table-container { /* For responsive tables if needed */
    overflow-x: auto;
    margin-bottom: 1rem; /* Add some space below tables */
}
table.table { /* More specific selector for dashboard table */
    width: 100%;
    border-collapse: collapse;
    margin-top: 1em; /* User's original margin */
    color: #212529;
}
table.table th, 
table.table td {
    border: 1px solid #dee2e6; /* Slightly lighter border */
    padding: 0.85rem; /* More padding */
    text-align: left;
    vertical-align: top;
}
table.table th {
    background-color: #f1f3f5; /* Lighter header background */
    font-weight: 500;
    border-bottom: 2px solid #ced4da; /* Stronger bottom border for header */
}
table.table tbody tr:nth-child(odd) {
    background-color: #f8f9fa; /* Subtle striping */
}
table.table tbody tr:hover {
    background-color: rgba(225, 101, 6, 0.075); /* Light orange tint on hover */
}

/* Styles for Editable Line Item Table */
.table-editable-lines {
    width: 100%;
    margin-bottom: 1rem;
    color: #212529;
    border-collapse: collapse;
}
.table-editable-lines th,
.table-editable-lines td {
    padding: 0.65rem; 
    vertical-align: middle; 
    border: 1px solid #dee2e6;
    text-align: left;
}
.table-editable-lines thead th {
    background-color: #f1f3f5;
    font-weight: 500;
    white-space: nowrap; 
}
.table-editable-lines td .form-control { /* Inputs within the table */
    padding: 0.4em 0.6em; 
    font-size: 0.95em;
    margin-bottom: 0; /* Remove margin if inside table cell */
}
.table-editable-lines textarea.form-control {
    min-height: 40px; 
    font-size: 0.95em;
    margin-bottom: 0;
}


/* --- Edit Invoice Page Specifics --- */
.edit-layout-container {
    display: flex;
    flex-wrap: nowrap; 
    gap: 25px;
    align-items: flex-start; 
}

.image-preview-pane {
    flex: 0 0 35%; 
    max-width: 35%; 
    position: sticky;
    top: 20px; 
    height: calc(100vh - 40px); 
    overflow-y: auto; 
    padding-right: 10px;
}
.image-preview-pane h3 {
    margin-top: 0;
    color: #495057;
    font-size: 1.3em; 
    margin-bottom: 10px;
}
.image-preview-pane img {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background-color: #fff;
    padding: 5px;
    width: 100%; 
    object-fit: contain; 
}

.form-pane {
    flex: 1 1 65%; 
    min-width: 0; 
}
/* .form-pane .card is already styled by general .card */
.form-pane .card-header h4 { 
    font-size: 1.25em;
    color: #343A40;
}


/* --- Utility Classes --- */
.text-center { text-align: center; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }

/* --- Responsive adjustments --- */
@media (max-width: 1024px) { 
    .edit-layout-container {
        flex-direction: column; 
        flex-wrap: wrap; 
    }
    .image-preview-pane {
        position: static; 
        width: 100%;
        max-width: 100%;
        flex: 0 0 auto; 
        height: auto; 
        max-height: 60vh; 
        overflow-y: auto;
        margin-bottom: 25px;
        padding-right: 0;
    }
    .form-pane {
        width: 100%;
        flex: 1 1 auto; 
    }
}

@media (max-width: 768px) {
    nav.navbar .container {
        flex-direction: column;
        align-items: flex-start;
    }
    nav.navbar .nav-links {
        margin-top: 10px;
        width: 100%; /* Make links take full width for better tap targets */
    }
    nav.navbar .nav-links a {
        margin-left: 0;
        display: block; /* Stack nav links */
        padding: 0.5em 0; /* Add padding to stacked links */
    }
    nav.navbar .nav-user-info {
        margin-right: 0;
        margin-bottom: 10px; /* Space below user info when stacked */
    }

    .form-row .form-group { /* Stack header fields on smaller screens */
        min-width: 100%; 
        flex-basis: 100%;
    }
    /* Adjust table font sizes or padding for smaller screens if needed */
    .table-editable-lines th,
    .table-editable-lines td {
        padding: 0.5rem;
        font-size: 0.9em;
    }
    .table-editable-lines td .form-control,
    .table-editable-lines textarea.form-control {
        font-size: 0.9em;
    }
}

/* --- Progress Indicator & Navigation --- */
.edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5em;
    flex-wrap: wrap;
    gap: 15px;
}

.progress-info {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 12px 18px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    font-size: 0.95em;
    color: #495057;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-info strong {
    color: #e16506;
    font-weight: 600;
}

.navigation-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-skip {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.btn-skip:hover {
    background-color: #5a6268;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.btn-skip:disabled {
    background-color: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.last-pending-indicator {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    padding: 10px 16px;
    border-radius: 6px;
    border: 1px solid #c3e6cb;
    font-size: 0.9em;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* --- Dashboard Enhancements --- */
.dashboard-stats {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #dee2e6;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    text-align: center;
}

.stat-card {
    background: white;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat-number {
    font-size: 2em;
    font-weight: bold;
    color: #e16506;
    display: block;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9em;
    color: #6c757d;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Button Enhancements --- */
.btn-success {
    background-color: #28a745;
    border-color: #28a745;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-success:hover {
    background-color: #218838;
    border-color: #1e7e34;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.btn-warning {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #212529;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-warning:hover {
    background-color: #e0a800;
    border-color: #d39e00;
    color: #212529;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.btn-info {
    background-color: #17a2b8;
    border-color: #17a2b8;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.btn-info:hover {
    background-color: #138496;
    border-color: #117a8b;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* --- Lock Indicator --- */
.lock-indicator {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #ffeaa7;
    font-size: 0.85em;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* --- Add Line Item Button --- */
.add-line-item-btn {
    background: linear-gradient(135deg, #e16506 0%, #c85a05 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 15px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.add-line-item-btn:hover {
    background: linear-gradient(135deg, #c85a05 0%, #a84a04 100%);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(225, 101, 6, 0.3);
}

/* --- Delete Button --- */
.delete-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.delete-btn:hover {
    background-color: #c82333;
    transform: scale(1.05);
}

/* --- Responsive Updates for New Elements --- */
@media (max-width: 768px) {
    .edit-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .navigation-buttons {
        justify-content: center;
    }
    
    .progress-info {
        text-align: center;
        order: -1;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 12px;
    }
    
    .stat-number {
        font-size: 1.5em;
    }
    
    .btn-skip,
    .btn-success,
    .btn-warning,
    .btn-info {
        padding: 10px 16px;
        font-size: 0.9em;
    }
}

/* ===== DataTables Search and Pagination Styles ===== */
/* Top section with search on the right */
.dataTables_wrapper .top {
    display: flex !important;
    justify-content: flex-end !important;
    align-items: center !important;
    padding: 15px 20px 10px 20px;
    margin-bottom: 0;
}

.dataTables_wrapper .dataTables_filter {
    float: none !important;
    text-align: right !important;
    margin: 0 !important;
}

.dataTables_wrapper .dataTables_filter label {
    font-weight: 500;
    color: #495057;
    display: flex !important;
    align-items: center;
    gap: 8px;
}

.dataTables_wrapper .dataTables_filter input {
    margin: 0 !important;
    display: inline-block !important;
    width: 250px !important;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    background-color: #fff;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: #007bff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Bottom pagination section */
.dataTables_wrapper .bottom {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    margin-top: 20px;
    min-height: 50px;
    flex-wrap: nowrap !important;
}

.dataTables_wrapper .bottom .left {
    display: flex !important;
    align-items: center !important;
    color: #6c757d;
    font-size: 14px;
    font-weight: 500;
    margin: 0 !important;
    flex: 0 0 auto;
    white-space: nowrap;
}

.dataTables_wrapper .bottom .right {
    display: flex !important;
    align-items: center !important;
    margin: 0 !important;
    flex: 0 0 auto;
    white-space: nowrap;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_info {
    display: none !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 8px 12px;
    margin: 0 3px;
    border: 1px solid #dee2e6;
    background: #ffffff;
    color: #6c757d;
    text-decoration: none;
    border-radius: 6px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    min-width: 36px;
    height: 36px;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    float: none !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background-color: #f8f9fa;
    border-color: #adb5bd;
    color: #495057;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover svg {
    stroke: #495057;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background-color: #007bff;
    border-color: #007bff;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,123,255,0.25);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background-color: #0056b3;
    border-color: #0056b3;
    color: #ffffff;
    transform: none;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current svg {
    stroke: #ffffff;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    background-color: #f8f9fa;
    border-color: #e9ecef;
    color: #adb5bd;
    cursor: not-allowed;
    box-shadow: none;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    background-color: #f8f9fa;
    border-color: #e9ecef;
    color: #adb5bd;
    transform: none;
    box-shadow: none;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled svg {
    stroke: #adb5bd;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.previous,
.dataTables_wrapper .dataTables_paginate .paginate_button.next {
    font-weight: 600;
    padding: 8px 10px;
}

.dataTables_wrapper .dataTables_paginate {
    white-space: nowrap;
}

.custom-length-select {
    padding: 2px 6px;
    border: 1px solid #ced4da;
    border-radius: 3px;
    font-size: 14px;
    background: white;
    margin: 0 3px;
    color: #495057;
}