/* =================================================================
   Global Styles & Variables
   ================================================================= */
:root {
    --primary-color: #a02020;
    --primary-hover: #801818;
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --text-dark: #333333;
    --text-light: #666666;
    --border-color: #dee2e6;
    --font-family: 'Poppins', sans-serif;
}

body {
    font-family: var(--font-family);
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-dark);
}

* {
    box-sizing: border-box;
}

/* =================================================================
   Landing Page (index.php)
   ================================================================= */
.landing-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.landing-box {
    background-color: var(--card-background);
    padding: 40px 50px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.landing-box .logo, .login-box .logo {
    max-width: 80px;
    margin: 0 auto 15px auto;
    display: block;
}

.landing-box h1, .login-box h1 {
    font-size: 36px;
    color: var(--primary-color);
    margin-bottom: 5px;
    font-weight: 600;
}

.landing-box h2, .login-box h2 {
    font-size: 18px;
    color: var(--text-light);
    margin-top: 0;
    margin-bottom: 25px;
    font-weight: 400;
}

.landing-box p {
    font-size: 16px;
    color: #555;
    margin-bottom: 30px;
}

.btn-landing {
    width: 100%;
    font-size: 18px;
    font-weight: 500;
    padding: 15px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.landing-footer {
    padding-top: 40px;
    font-size: 14px;
    color: #999;
}


/* =================================================================
   Login Page (login.php)
   ================================================================= */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: var(--card-background);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-box h1 {
    font-size: 32px;
}

.login-box h2 {
    font-size: 16px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn {
    display: inline-block;
    padding: 12px 20px;
    border-radius: 6px;
    border: none;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    width: 100%;
    padding: 14px;
    font-size: 17px;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
}

.alert {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 6px;
    text-align: center;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}


/* =================================================================
   Main Dashboard Layout & Header
   ================================================================= */
.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    margin-bottom: 30px;
    background-color: var(--card-background);
    padding: 15px 25px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-content .logo {
    height: 40px;
    width: auto;
}

.header-text h1 {
    font-size: 20px;
    margin: 0;
    font-weight: 600;
    color: var(--primary-color);
}

.header-text p {
    margin: 0;
    font-size: 14px;
    color: var(--text-light);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-logout {
    background-color: #6c757d;
    color: white;
    padding: 8px 15px;
    font-size: 14px;
}
.btn-logout:hover {
    background-color: #5a6268;
}

/* =================================================================
   Team Dashboard Specifics
   ================================================================= */
.search-container {
    background-color: var(--card-background);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    margin-bottom: 25px;
}

#customer-search-form {
    display: flex;
    gap: 15px;
    align-items: center;
}

.search-bar {
    flex-grow: 1;
    position: relative;
}

.search-icon {
    position: absolute;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
    color: #aaa;
}

#phone-number {
    width: 100%;
    padding: 15px 15px 15px 45px; /* Add padding for the icon */
    font-size: 18px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: border-color 0.3s ease;
}
#phone-number:focus {
    outline: none;
    border-color: var(--primary-color);
}

#customer-search-form .btn-primary {
    width: 200px;
    padding: 15px;
    font-size: 16px;
}

.placeholder {
    text-align: center;
    padding: 50px;
    color: #888;
    background-color: #fdfdfd;
    border-radius: 8px;
    border: 1px dashed #ddd;
}
.placeholder i {
    font-size: 28px;
    margin-bottom: 10px;
    display: block;
    color: #ccc;
}
.placeholder.error {
    color: #721c24;
    border-color: #f5c6cb;
    background-color: #f8d7da;
}

/* Customer Card & Tabs */
.customer-card, .new-customer-card {
    background: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.07);
    overflow: hidden;
}

.customer-profile {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    padding: 25px;
    background-color: #fdf5f5;
    border-bottom: 1px solid #f0dada;
}

.profile-info { display: flex; align-items: center; gap: 15px; }
.profile-icon { font-size: 48px; color: var(--primary-color); }
.customer-name { display: block; font-size: 20px; font-weight: 600; }
.customer-phone { font-size: 16px; color: #555; }
.profile-stats { display: flex; gap: 30px; }
.stat-item { text-align: right; }
.stat-item span { font-size: 14px; color: #777; display: block; }
.stat-item strong { font-size: 20px; font-weight: 600; color: var(--primary-color); }

.tabs { display: flex; border-bottom: 1px solid #eee; padding: 0 25px; }
.tab-button { padding: 15px 20px; cursor: pointer; background: none; border: none; font-size: 16px; font-weight: 500; color: #666; border-bottom: 3px solid transparent; transition: all 0.3s ease; }
.tab-button.active { color: var(--primary-color); border-bottom-color: var(--primary-color); }
.tab-content { padding: 25px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* New Customer Form */
.new-customer-card { padding: 30px; }
.info-message { text-align: center; padding: 15px; background-color: #e2e3e5; color: #40444a; border-radius: 4px; margin-bottom: 25px; }
#add-customer-form { display: flex; gap: 15px; }
.new-customer-input { flex-grow: 1; }
.new-customer-input label { display: block; margin-bottom: 8px; font-weight: 500; }
#new-customer-name { width: 100%; padding: 15px; font-size: 16px;}
#add-customer-form .btn { width: 300px; align-self: flex-end; padding: 15px; }

/* Order & Past Order Tables */
.order-table, .past-order-table, .customers-table { width: 100%; border-collapse: collapse; }
.order-table th, .order-table td,
.past-order-table th, .past-order-table td,
.customers-table th, .customers-table td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    text-align: left;
}
.order-table th, .past-order-table th, .customers-table th {
    background-color: #f9f9f9;
    font-weight: 500;
    color: #555;
    font-size: 14px;
}
.order-input { width: 100px; padding: 8px; border-radius: 4px; border: 1px solid #ccc; font-size: 15px; text-align: right; }
.order-input.total-price { width: 120px; }
.order-unit-select { padding: 8px; border-radius: 4px; border: 1px solid #ccc; font-size: 15px; background-color: #fff; }
.order-input:focus, .order-unit-select:focus { outline: none; border-color: var(--primary-color); }
.subtotal, .text-right { text-align: right !important; }

.order-summary { display: flex; justify-content: flex-end; align-items: center; padding-top: 20px; border-top: 1px solid #eee; }
.total-section { font-size: 20px; font-weight: 500; margin-right: 25px; }
.total-section strong { color: var(--primary-color); font-weight: 600; }

.past-order-card { background-color: #fff; border: 1px solid #e0e0e0; border-radius: 8px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.past-order-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; background-color: #f9f9f9; border-bottom: 1px solid #e0e0e0; flex-wrap: wrap; }
.order-header-total strong, .order-header-stat strong { font-size: 20px; color: var(--primary-color); }
.whatsapp-btn { background-color: #25D366 !important; width: auto !important; padding: 10px 20px !important; display: flex; align-items: center; gap: 8px; }
.whatsapp-btn:hover { background-color: #1EBE57 !important; }
.past-order-body { padding: 10px; }
.order-header-stat { text-align: right; }
.order-header-stat span { font-size: 14px; color: #777; display: block; }

/* Styles for the updated Order Summary */
.order-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}
.summary-item {
    display: flex;
    flex-direction: column;
}
.summary-item span, .summary-item label {
    font-size: 14px;
    color: #777;
    margin-bottom: 5px;
}
.summary-item strong {
    font-size: 18px;
    font-weight: 600;
}
.summary-item#total-weight {
    color: #333;
}
.summary-item.total-section strong {
    font-size: 22px;
    color: var(--primary-color);
}
.order-summary .btn {
    margin-left: auto;
}
.past-order-body .fee-row td {
    font-weight: 600;
    background-color: #f9f9f9;
}


/* Autocomplete Styles */
.search-bar-wrapper {
    position: relative; /* Needed for absolute positioning of results */
    flex-grow: 1;
}

.autocomplete-results-list {
    position: absolute;
    top: 100%; /* Position below the input */
    left: 0;
    right: 0;
    background-color: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000; /* Ensure it appears above other content */
    display: none; /* Hidden by default */
}

.autocomplete-results-list ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.autocomplete-results-list li {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.autocomplete-results-list li:last-child {
    border-bottom: none;
}

.autocomplete-results-list li:hover {
    background-color: #f5f5f5;
}

.ac-name {
    font-weight: 500;
}

.ac-phone {
    font-size: 0.9em;
    color: #777;
}


/* =================================================================
   Management Dashboard
   ================================================================= */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 25px; margin-bottom: 30px; }
.stat-card { background-color: #fff; padding: 25px; border-radius: 8px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06); display: flex; align-items: center; gap: 20px; }
.stat-card i { font-size: 36px; color: var(--primary-color); background-color: #fdf5f5; padding: 15px; border-radius: 50%; }
.stat-info strong { font-size: 28px; font-weight: 600; }
.stat-info span { font-size: 15px; color: #777; }
.customers-table-card { background-color: #fff; padding: 25px; border-radius: 8px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06); }
.customers-table-card h2 { margin-top: 0; margin-bottom: 20px; font-size: 20px; }
.customers-table tbody tr:hover { background-color: #fdf5f5; }

/* =================================================================
   Media Queries for Responsiveness
   ================================================================= */
@media (max-width: 768px) {
    /* General Layout */
    .dashboard-container { padding: 10px; }
    .landing-box, .login-box { padding: 25px; }
    .dashboard-header { flex-direction: column; align-items: center; gap: 15px; padding: 20px; }
    .user-info { width: 100%; justify-content: space-between; }

    /* Search Form */
    #customer-search-form { flex-direction: column; align-items: stretch; }
    #customer-search-form .btn-primary { width: 100%; }

    /* Customer Profile Card */
    .customer-profile { flex-direction: column; align-items: center; text-align: center; }
    .profile-stats { flex-direction: column; gap: 15px; width: 100%; margin-top: 15px; }
    .profile-stats .stat-item { text-align: center; display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border-bottom: 1px solid #f0dada; }
    .profile-stats .stat-item:last-child { border-bottom: none; }
    .profile-stats .stat-item span { text-align: left; }
    .profile-stats .stat-item strong { text-align: right; }
    
    /* Tabs */
    .tabs { justify-content: center; }
    .tab-content { padding: 15px; }

    /* Add Customer Form */
    #add-customer-form { flex-direction: column; }
    #add-customer-form .btn { width: 100%; }

    /* Past Orders Header */
    .past-order-header { align-items: center; gap: 10px; }
    .order-header-stat { width: 100%; display: flex; justify-content: space-between; align-items: center; text-align: left; padding: 5px 0; }
    .order-header-stat strong { text-align: right; }
    
    /* Tables */
    .customers-table { display: block; width: 100%; overflow-x: auto; }

    /* CORRECTED RESPONSIVE TABLES (BOTH ORDER & PAST ORDER) */
    .order-table thead, .past-order-table thead { display: none; }
    .order-table tr, .past-order-table tr { display: block; border-bottom: 1px solid #eee; padding: 10px 0; }
    .order-table tr:last-child, .past-order-table tr:last-child { border-bottom: none; }
    .order-table td, .past-order-table td { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; border: none; font-size: 0.95em; }
    
    /* Item Name is always on top */
    .order-table td:first-child, .past-order-table td:first-child { display: block; width: 100%; font-weight: 600; color: var(--text-dark); margin-bottom: 5px; font-size: 1em; text-align: left; }
    
    /* Use data-label from JS for labels */
    .order-table td::before, .past-order-table td::before { 
        content: attr(data-label); 
        font-weight: 500;
        color: var(--text-light);
    }
    .order-table td:first-child::before, .past-order-table td:first-child::before {
        display: none; /* Do not show "Item:" label */
    }
    
    .order-input, .order-unit-select {
        width: 130px; /* Give a bit more space */
    }
    .order-summary { flex-direction: column; align-items: stretch; gap: 15px; }
    .total-section { display: flex; justify-content: space-between; font-size: 18px; padding: 15px; background-color: #fdf5f5; border-radius: 8px; }
    .order-summary .btn { width: 100%; }
        .order-summary {
        flex-direction: column;
        align-items: stretch;
    }
    .order-summary .btn {
        margin-left: 0;
        width: 100%;
    }
    .summary-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 10px;
        background-color: #fdf5f5;
        border-radius: 8px;
    }
    .summary-item label {
        margin-bottom: 0;
    }
     #customer-search-form .btn-primary {
         margin-top: 10px; /* Add some space when button stacks */
    }
     .search-bar-wrapper {
        width: 100%; /* Take full width when stacked */
    }
}

