/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* General Styles */
html {
    font-size: 16px;
    scroll-behavior: smooth;
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'Roboto', sans-serif;
    line-height: 1.6;
    background: linear-gradient(to right, #f0f2f5, #ffffff);
    color: #333;
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 85vh;
    overflow-x: hidden;
    width: 100%;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    background: #ffffff;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

h1, h2, h3 {
    font-family: 'Poppins', sans-serif;
    margin-bottom: 1rem;
    color: #222;
}

p {
    margin-bottom: 1rem;
    color: #555;
}

/* Buttons */
button {
    display: inline-block;
    background: #007bff;
    color: #fff;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.3s ease;
}

button:hover {
    background: #0056b3;
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 1rem;
    background: #ffffff;
    color: #333;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background: #007bff;
    color: #fff;
    font-weight: bold;
    text-transform: uppercase;
}

tr:nth-child(even) {
    background: #f9f9f9;
}

tr:hover {
    background: #e0f7fa;
    transition: background-color 0.3s ease;
}

/* Input and Textarea Styles */
input, textarea, select {
    width: 100%;
    padding: 1px;
    margin: 1px 0;
    border: 1px solid #ddd;
    border-radius: 0.5rem;
    font-size: 1rem;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 4px rgba(0, 123, 255, 0.5);
}

/* --- Unified Input Styles for All Forms --- */
input[type="text"], input[type="password"], input[type="email"], input[name="fullName"] {
  width: 100%;
  margin: 10px 0;
  text-align: center;
  background: #23272a !important;
  color: #f5f6fa !important;
  border: 1.5px solid #586069 !important;
  border-radius: 6px !important;
  padding: 10px !important;
  box-sizing: border-box;
  appearance: none;
  font-size: 1rem;
}
input:focus {
  outline: none;
  border-color: #7289da !important;
  box-shadow: 0 0 4px #7289da44;
}

/* Top Bar Styles */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #007bff;
    cursor: pointer;
    transition: background 0.3s ease;
}

.top-bar .logout-button:hover {
    background: #ff9966;
}

/* Footer Styles */
.footer {
    text-align: center;
    padding: 1rem;
    background: #007bff;
    color: #fff;
    margin-top: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }

    button {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    table {
        font-size: 0.9rem;
    }

    th, td {
        padding: 1px;
    }
}

.back-btn-mobile {
    display: inline-block;
    width: 100%;
    max-width: 350px;
    margin: 20px auto 0 auto;
    padding: 14px 0;
    font-size: 1.1rem;
    background: #444851;
    color: #f5f6fa;
    border: 2px solid #586069;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.back-btn-mobile:active {
    background: #586069;
    border-color: #7289da;
}

@media (max-width: 480px) {
    .back-btn-mobile {
        font-size: 1rem;
        padding: 12px 0;
    }
}

/* Delete Row Button Styles */
.delete-row-btn {
  background: #dc3545 !important;
  color: #fff !important;
  border: none !important;
  padding: 2px 8px !important;
  border-radius: 4px !important;
  cursor: pointer !important;
  font-size: 1.1em !important;
  transition: background 0.2s;
}
.delete-row-btn:hover {
  background: #b52a37 !important;
}

/* Simple Pack Highlighting Styles - Absolutely no movement approach */
.highlighted-bag {
  position: relative !important;
  transition: none !important;
  transform: none !important;
  background-color: #d4f6d4 !important; /* Light green background */
}

.highlighted-bag::after {
  content: '' !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  border: 3px solid #007bff !important;
  pointer-events: none !important;
  z-index: 10 !important;
  box-sizing: border-box !important;
}

/* Permanent highlighted bag - slightly different style */
.highlighted-bag.permanent {
  background-color: #c8e6c9 !important; /* Slightly darker green for permanent */
}

.highlighted-bag.permanent::after {
  border: 2px solid #28a745 !important; /* Green border for permanent highlights */
}

.highlighted-bag td {
  font-weight: bold !important;
  position: relative !important;
  z-index: 5 !important;
  background-color: inherit !important; /* Inherit the light green from parent */
}

/* Delivery Locations Styles */
.locations-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    text-align: center;
}

.header h1 {
    margin: 0;
    font-size: 28px;
}

.tabs {
    display: flex;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
}

.tab {
    flex: 1;
    padding: 15px;
    background: #e9ecef;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.tab.active {
    background: #007bff;
    color: white;
}

.tab:hover:not(.active) {
    background: #dee2e6;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.form-container {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 200px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid #e9ecef;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #007bff;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
    margin: 5px;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
    transform: translateY(-2px);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #1e7e34;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

.locations-table {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.table-container {
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    border-radius: 10px;
    /* Ensure smooth scrolling */
    scroll-behavior: smooth;
    /* Custom scrollbar for better UX */
}

.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.locations-table table {
    width: 100%;
    min-width: 1400px;
    border-collapse: collapse;
    table-layout: fixed;
}

.locations-table th, 
.locations-table td {
    padding: 12px;
    text-align: right;
    border-bottom: 1px solid #e9ecef;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Specific column widths */
.locations-table th:nth-child(1),
.locations-table td:nth-child(1) { width: 12%; } /* المستخدم */

.locations-table th:nth-child(2),
.locations-table td:nth-child(2) { width: 10%; } /* نوع الموقع */

.locations-table th:nth-child(3),
.locations-table td:nth-child(3) { 
    width: 20%; 
    white-space: normal;
    word-wrap: break-word;
    max-width: 200px;
} /* العنوان */

.locations-table th:nth-child(4),
.locations-table td:nth-child(4) { 
    width: 15%; 
    font-size: 11px;
} /* الإحداثيات */

.locations-table th:nth-child(5),
.locations-table td:nth-child(5) { 
    width: 15%; 
    white-space: normal;
    word-wrap: break-word;
    max-width: 150px;
} /* ملاحظات */

.locations-table th:nth-child(6),
.locations-table td:nth-child(6) { width: 12%; } /* تاريخ الإضافة */

.locations-table th:nth-child(7),
.locations-table td:nth-child(7) { width: 10%; } /* أنشئ بواسطة */

.locations-table th:nth-child(7),
.locations-table td:nth-child(7) { 
    width: 28%; 
    min-width: 360px;
    padding: 8px 12px;
} /* العمليات */

.locations-table th {
    background: #f8f9fa;
    font-weight: bold;
    color: #495057;
}

.locations-table tr:hover {
    background: #f8f9fa;
}

.action-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
    flex-wrap: wrap;
    align-items: center;
    min-width: 300px;
    overflow: visible;
    padding: 4px 0;
}

.action-buttons button {
    padding: 8px 12px;
    font-size: 13px;
    min-width: 70px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Waze button specific styling */
.action-buttons button[onclick*="openInWaze"] {
    background: #00d4aa !important;
    border-color: #00d4aa !important;
    color: white;
    font-weight: bold;
}

.action-buttons button[onclick*="openInWaze"]:hover {
    background: #00b894 !important;
    border-color: #00b894 !important;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.loading::after {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-radius: 50%;
    border-top: 3px solid #007bff;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.message {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    font-weight: bold;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.coordinates-display {
    font-family: monospace;
    font-size: 12px;
    color: #6c757d;
}

.map-container {
    height: 300px;
    min-height: 300px;
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin: 15px 0;
    position: relative;
    z-index: 1;
    display: block;
    visibility: visible;
}

.map-controls {
    text-align: center;
    margin: 10px 0;
}

.filter-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-number {
    font-size: 32px;
    font-weight: bold;
    color: #007bff;
    margin-bottom: 5px;
}

.stat-label {
    color: #6c757d;
    font-size: 14px;
}

/* Mobile responsive styles for delivery locations */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
    }

    .tabs {
        flex-direction: column;
    }

    .action-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 2px;
        min-width: auto;
        width: 100%;
        justify-content: flex-start;
    }
    
    .locations-table th:nth-child(7),
    .locations-table td:nth-child(7) { 
        min-width: 200px;
        width: 150px;
        padding: 4px 2px;
    }

    .stats-cards {
        grid-template-columns: 1fr;
    }
    
    .locations-container {
        padding: 10px;
    }
    
    .locations-table table {
        min-width: 900px;
    }
    
    .locations-table th, 
    .locations-table td {
        padding: 6px 3px;
        font-size: 11px;
    }
    
    .action-buttons button {
        padding: 3px 4px;
        font-size: 10px;
        margin: 1px;
        min-width: 35px;
        width: auto;
        flex: 0 0 auto;
    }
    
    /* Hide button text on mobile, show only icons */
    .action-buttons button[onclick*="openInWaze"] {
        font-size: 9px;
        padding: 4px 6px;
    }
}

@media (max-width: 1600px) {
    .locations-container {
        max-width: 100%;
        padding: 15px;
    }
    
    .locations-table table {
        min-width: 1300px;
    }
}

@media (max-width: 1200px) {
    .locations-table table {
        min-width: 1100px;
    }
    
    .locations-table th:nth-child(7),
    .locations-table td:nth-child(7) {
        min-width: 280px;
        width: 25%;
    }
}

/* Additional mobile optimization for very small screens */
@media (max-width: 480px) {
    .action-buttons {
        gap: 1px;
    }
    
    .action-buttons button {
        padding: 2px 3px;
        font-size: 9px;
        min-width: 30px;
        border-radius: 3px;
    }
    
    .action-buttons button[onclick*="openInWaze"] {
        padding: 3px 4px;
        font-size: 8px;
    }
    
    .locations-table th:nth-child(7),
    .locations-table td:nth-child(7) {
        min-width: 150px;
        width: 120px;
    }
    
    .locations-table table {
        min-width: 700px;
    }
}

/* Ensure main content doesn't overflow */
.locations-container {
    overflow-x: hidden;
}
