/* Reset และพื้นฐาน */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans Lao', 'Phetsarath OT', 'Saysettha OT', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: #2c3e50;
    color: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.user-info {
    font-size: 0.9rem;
}

.user-info a {
    color: #ecf0f1;
    text-decoration: none;
}

.user-info a:hover {
    text-decoration: underline;
}

/* Navigation */
.main-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.nav-item {
    background: white;
    padding: 20px;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.nav-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.nav-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.nav-text {
    font-weight: bold;
    font-size: 1.1rem;
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
    color: #7f8c8d;
    margin-bottom: 15px;
    font-size: 1rem;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
}

/* Forms */
.content-section {
    background: white;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 25px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.content-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ecf0f1;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-family: inherit;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #219a52;
}

.btn-warning {
    background: #f39c12;
    color: white;
}

.btn-warning:hover {
    background: #d68910;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.9rem;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ecf0f1;
}

.data-table th {
    background: #34495e;
    color: white;
    font-weight: bold;
}

.data-table tr:hover {
    background: #f8f9fa;
}

.data-table td {
    background: white;
}

/* Alerts */
.alert {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Login Page */
.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.login-form h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #2c3e50;
}

/* Date Filter */
.date-filter,
.date-filter-form {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

.inline-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* No Data */
.no-data {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .main-nav {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .data-table {
        font-size: 0.9rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
    }

    .login-container {
        margin: 20px;
        padding: 30px 20px;
    }
}

@media (max-width: 480px) {
    .btn {
        width: 100%;
        margin-bottom: 5px;
    }

    .data-table td:last-child {
        text-align: center;
    }

    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-form .btn {
        width: 100%;
    }
}

/* เพิ่มใน style.css */

/* Customer Info in Debt Form */
.customer-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    margin-top: 10px;
    border-left: 4px solid #3498db;
}

.customer-details {
    margin-bottom: 10px;
}

.customer-image {
    text-align: center;
}

.customer-image img {
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Location Input */
.location-input-group {
    display: flex;
    gap: 10px;
}

.location-input-group input {
    flex: 1;
}

.location-status {
    display: block;
    margin-top: 5px;
    font-style: italic;
}

.location-status.loading {
    color: #f39c12;
}

.location-status.success {
    color: #27ae60;
}

.location-status.error {
    color: #e74c3c;
}

.location-link {
    color: #3498db;
    text-decoration: none;
}

.location-link:hover {
    text-decoration: underline;
}

/* Customer Profile */
.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #ecf0f1;
}

.profile-details {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.detail-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.detail-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.detail-group label {
    font-weight: bold;
    color: #555;
}

.detail-group span,
.detail-group p {
    color: #333;
}

/* Status Badges */
.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
}

.status-paid {
    background: #d4edda;
    color: #155724;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

/* Debt Summary */
.debt-summary {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
    text-align: center;
}

.total-pending {
    font-size: 1.5rem;
    font-weight: bold;
    color: #e74c3c;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Current Image */
.current-image {
    margin-bottom: 15px;
}

.current-image img {
    border: 2px solid #ddd;
    border-radius: 4px;
}

/* Total Amount Display */
.total-amount-display {
    font-weight: bold;
    font-size: 1.1rem;
    color: #2c3e50;
}

/* Map Preview */
#map-preview {
    margin-top: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
}

/* Responsive */
@media (max-width: 768px) {
    .detail-row {
        grid-template-columns: 1fr;
    }

    .location-input-group {
        flex-direction: column;
    }

    .profile-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .form-actions {
        flex-direction: column;
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 2% auto;
    padding: 0;
    border-radius: 8px;
    width: 95%;
    max-width: 1200px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.modal-header {
    background: #2c3e50;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #ecf0f1;
}

.modal-body {
    padding: 20px;
    max-height: calc(90vh - 140px);
    overflow-y: auto;
}

/* Search Section */
.search-section {
    margin-bottom: 20px;
}

.search-section input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.search-section input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

/* Modal Table */
.modal-table {
    font-size: 0.9rem;
}

.modal-table th {
    background: #34495e;
    color: white;
    padding: 12px 8px;
    font-weight: bold;
}

.modal-table td {
    padding: 10px 8px;
    vertical-align: middle;
}

.modal-table .details-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-table .image-cell {
    text-align: center;
}

.modal-table .image-cell img {
    border-radius: 4px;
    border: 1px solid #ddd;
}

.no-image {
    color: #7f8c8d;
    font-style: italic;
}

/* Customer Selector */
.customer-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.customer-selector .btn {
    width: fit-content;
    min-width: 200px;
}

#selected-customer-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    border-left: 4px solid #3498db;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
}

.customer-details {
    flex: 1;
}

.customer-details div {
    margin-bottom: 5px;
}

.customer-image {
    flex-shrink: 0;
}

.customer-image img {
    border-radius: 4px;
    border: 1px solid #ddd;
}

/* Responsive Modal */
@media (max-width: 768px) {
    .modal-content {
        width: 98%;
        margin: 1% auto;
    }

    .modal-header {
        padding: 15px;
    }

    .modal-body {
        padding: 15px;
    }

    .modal-table {
        font-size: 0.8rem;
    }

    .modal-table th,
    .modal-table td {
        padding: 8px 4px;
    }

    #selected-customer-info {
        flex-direction: column;
        gap: 10px;
    }

    .customer-image {
        align-self: flex-start;
    }
}

@media (max-width: 480px) {
    .modal-header h2 {
        font-size: 1.2rem;
    }

    .close {
        font-size: 24px;
    }

    .modal-table {
        font-size: 0.7rem;
    }

    .btn-sm {
        padding: 3px 6px;
        font-size: 0.7rem;
    }
}

/* Animation for Modal */
.modal-content {
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar for Modal */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Customer Selector Buttons */
.customer-selector-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.customer-selector-buttons .btn {
    min-width: 150px;
}

/* Modal Actions Styles */
.modal-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    flex-wrap: wrap;
}

.modal-actions .search-section {
    flex: 1;
    min-width: 300px;
}

.modal-actions .action-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.modal-actions .btn {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    padding: 10px 15px;
}

.btn-icon {
    font-size: 1.1em;
}

/* No Customers Message */
.no-customers-message {
    text-align: center;
    padding: 40px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
}

.no-customers-message .no-data {
    margin-bottom: 20px;
    font-size: 1.1em;
    color: #6c757d;
}

.no-customers-message .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 1.1em;
}

/* Customer Table Actions */
.modal-table .btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    font-size: 0.85em;
}

/* Customer Selector in Form */
.customer-selector-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.customer-selector-buttons .btn {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 150px;
    justify-content: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .modal-actions .search-section {
        min-width: auto;
    }

    .modal-actions .action-buttons {
        justify-content: center;
    }

    .customer-selector-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .customer-selector-buttons .btn {
        min-width: auto;
        width: 100%;
    }

    .modal-table .btn-sm {
        flex-direction: column;
        gap: 2px;
        padding: 4px 6px;
        font-size: 0.75em;
    }

    .btn-icon {
        font-size: 1em;
    }
}

@media (max-width: 480px) {
    .modal-actions {
        padding: 10px;
    }

    .modal-actions .btn {
        padding: 8px 12px;
        font-size: 0.9em;
    }

    .no-customers-message {
        padding: 30px 15px;
    }

    .no-customers-message .btn {
        padding: 10px 20px;
        font-size: 1em;
    }
}

/* Hover Effects */
.modal-actions .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.no-customers-message .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Animation for New Customer */
@keyframes highlightNew {
    0% {
        background-color: #d4edda;
    }

    50% {
        background-color: #c3e6cb;
    }

    100% {
        background-color: transparent;
    }
}

.customer-new {
    animation: highlightNew 2s ease-in-out;
}

/* Search Filter Form */
.search-filter-form {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.search-filter-form .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.search-filter-form .form-group {
    margin-bottom: 0;
}

.search-filter-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
    font-size: 0.9rem;
}

.search-filter-form input,
.search-filter-form select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.search-filter-form input:focus,
.search-filter-form select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

.search-filter-form .btn {
    margin-top: 25px;
}

/* Debt Summary */
.debt-summary {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
    text-align: center;
}

.debt-summary h4 {
    margin-bottom: 10px;
    color: #2c3e50;
}

.total-pending {
    font-size: 1.5rem;
    font-weight: bold;
    color: #e74c3c;
    margin-bottom: 5px;
}

.total-paid {
    font-size: 1.5rem;
    font-weight: bold;
    color: #27ae60;
    margin-bottom: 5px;
}

.debt-summary p {
    margin: 5px 0;
    color: #666;
}

/* Responsive Design */
@media (max-width: 768px) {
    .search-filter-form .form-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .search-filter-form {
        padding: 15px;
    }

    .debt-summary {
        padding: 10px;
    }

    .total-pending,
    .total-paid {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .search-filter-form {
        padding: 10px;
    }

    .search-filter-form .form-row {
        gap: 8px;
    }

    .search-filter-form input,
    .search-filter-form select {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    .debt-summary {
        padding: 8px;
    }

    .total-pending,
    .total-paid {
        font-size: 1.2rem;
    }
}

/* Table Responsive */
.table-responsive {
    overflow-x: auto;
    margin-bottom: 20px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ecf0f1;
    font-size: 0.9rem;
}

.data-table th {
    background: #34495e;
    color: white;
    font-weight: bold;
    position: sticky;
    top: 0;
}

.data-table tr:hover {
    background: #f8f9fa;
}

/* Button Styles in Table */
.data-table .btn-sm {
    padding: 4px 8px;
    font-size: 0.8rem;
    margin: 2px;
}

/* No Data Message */
.no-data {
    text-align: center;
    padding: 40px 20px;
    color: #7f8c8d;
    font-style: italic;
    background: #f8f9fa;
    border-radius: 4px;
}