/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* Header */
header {
    background-color: #1976d2;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo i {
    font-size: 1.5rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Navigation */
nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-btn {
    background: transparent;
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.nav-btn:hover {
    background-color: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.5);
}

.nav-btn.active {
    background-color: white;
    color: #1976d2;
    border-color: white;
}

/* Main Content */
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

.container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

h2 {
    background-color: #1976d2;
    color: white;
    padding: 1rem;
    margin: 0;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Forms */
.form-card {
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #1976d2;
}

/* Location Info */
.location-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#current-location {
    padding: 0.75rem;
    background-color: #f8f9fa;
    border: 2px solid #ddd;
    border-radius: 5px;
    min-height: 50px;
    display: flex;
    align-items: center;
}

/* Time Display */
.time-display {
    padding: 0.75rem;
    background-color: #e3f2fd;
    border: 2px solid #1976d2;
    border-radius: 5px;
    font-weight: 500;
    color: #1976d2;
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: #1976d2;
    color: white;
    width: 100%;
    justify-content: center;
}

.btn-primary:hover {
    background-color: #1565c0;
}

.btn-secondary {
    background-color: #f5f5f5;
    color: #666;
    border: 2px solid #ddd;
}

.btn-secondary:hover {
    background-color: #e0e0e0;
    border-color: #bbb;
}

/* Delivery Message */
.delivery-message {
    background-color: #f8f9fa;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.delivery-message h3 {
    color: #1976d2;
    margin-bottom: 1rem;
    text-align: center;
}

.message-content p {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.message-content span {
    color: #1976d2;
    font-weight: 500;
}

/* Checklist */
.checklist-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    background-color: #f8f9fa;
    padding: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.5rem;
    background: white;
    border-radius: 5px;
    border: 1px solid #eee;
    transition: all 0.2s ease;
}

.checkbox-item:hover {
    background-color: #e3f2fd;
    border-color: #1976d2;
}

.checkbox-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
    accent-color: #1976d2;
}

/* Rating System */
.rating-container {
    background-color: #f8f9fa;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
}

.rating-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.rating-item:last-child {
    margin-bottom: 0;
}

.rating-item span {
    font-weight: 500;
    min-width: 150px;
}

.stars {
    display: flex;
    gap: 0.25rem;
}

.stars i {
    font-size: 1.5rem;
    color: #ddd;
    cursor: pointer;
    transition: color 0.2s ease;
}

.stars i:hover {
    color: #ffd700;
}

.stars i.fas {
    color: #ffd700;
}

/* Signature */
.signature-container {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    background-color: #f8f9fa;
}

.signature-instructions {
    margin-bottom: 1rem;
    color: #666;
    font-style: italic;
}

#signature-pad {
    border: 2px solid #1976d2;
    border-radius: 5px;
    background-color: white;
    width: 100%;
    max-width: 500px;
    height: 200px;
    display: block;
    margin: 0 auto;
    touch-action: none; /* Prevent scrolling while signing */
}

.signature-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

/* History */
.history-card {
    padding: 2rem;
}

.search-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.search-bar input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.history-list {
    max-height: 600px;
    overflow-y: auto;
}

.history-item {
    background-color: #f8f9fa;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.history-item.checkin {
    border-left: 4px solid #4caf50;
}

.history-item.delivery {
    border-left: 4px solid #2196f3;
}

.item-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.item-id {
    margin-left: auto;
    color: #666;
    font-size: 0.9rem;
}

.item-details p {
    margin-bottom: 0.5rem;
}

.ratings-summary {
    background-color: #e3f2fd;
    padding: 0.75rem;
    border-radius: 5px;
    margin-top: 0.5rem;
}

.history-actions {
    margin-top: 10px;
    text-align: right;
}

.history-actions button,
.btn-view-doc {
    background-color: #1976d2;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.history-actions button:hover,
.btn-view-doc:hover {
    background-color: #1565c0;
}

.no-data {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem;
}

/* Footer */
footer {
    background-color: #333;
    color: white;
    text-align: center;
    padding: 1rem 0;
    margin-top: 3rem;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #1976d2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success Message */
.success-message {
    background: #e8f5e8;
    color: #2e7d32;
    padding: 1rem;
    border-radius: 10px;
    border: 2px solid #4caf50;
    margin: 1rem 0;
    text-align: center;
    font-weight: 600;
}

.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 1rem;
    border-radius: 10px;
    border: 2px solid #f44336;
    margin: 1rem 0;
    text-align: center;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .logo {
        width: 100%;
        justify-content: center;
    }

    nav {
        width: 100%;
        justify-content: center;
        gap: 0.5rem;
    }

    .nav-btn {
        flex: 1;
        text-align: center;
        white-space: nowrap;
        padding: 0.75rem 0.5rem;
        min-width: 100px;
    }

    .form-card, .history-card {
        padding: 1.5rem;
    }

    .rating-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        background: #fff;
        padding: 1rem;
        border-radius: 8px;
        border: 1px solid #eee;
    }

    .rating-item span {
        font-weight: 600;
        color: #1976d2;
    }

    .stars i {
        font-size: 2rem; /* Larger stars for touch */
        padding: 0.25rem;
    }

    .search-bar {
        flex-direction: column;
    }

    .search-bar button {
        width: 100%;
    }

    .signature-controls {
        flex-direction: column;
        gap: 0.75rem;
    }

    .signature-controls button {
        width: 100%;
    }

    .location-info {
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    h1 {
        font-size: 1.25rem !important;
    }

    h2 {
        font-size: 1.1rem;
        padding: 0.75rem;
    }

    .container {
        border-radius: 0; /* Full width on small screens */
        box-shadow: none;
    }

    main {
        margin: 0;
        padding: 0;
    }

    .form-card, .history-card {
        padding: 1rem;
    }

    .form-group input, 
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 0.875rem;
    }

    .btn-primary, .btn-secondary {
        padding: 0.875rem;
        font-size: 1rem;
    }

    /* Make signature pad responsive height */
    #signature-pad {
        height: 200px; /* Fixed height for mobile */
    }
    
    .delivery-message {
        padding: 1rem;
        margin: 1rem 0;
        font-size: 0.9rem;
    }
}
