/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #2196F3;
    --primary-dark: #1976D2;
    --primary-light: #BBDEFB;
    --accent: #FF5722;
    --success: #4CAF50;
    --warning: #FFC107;
    --danger: #f44336;
    --text-primary: #212121;
    --text-secondary: #757575;
    --background: #f5f5f5;
    --surface: #ffffff;
    --border: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--background);
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Screen Management */
.screen {
    display: none;
    flex: 1;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.screen.active {
    display: flex;
}

/* Login Screen */
#login-screen {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.login-container {
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.logo {
    margin-bottom: 48px;
    color: white;
}

.logo-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.logo h1 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
}

.logo p {
    opacity: 0.9;
    font-size: 16px;
}

.login-buttons {
    margin-bottom: 24px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-google {
    background: white;
    color: var(--text-primary);
    box-shadow: var(--shadow);
}

.btn-google:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

.btn-record {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: white;
    border: 4px solid var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.record-circle {
    width: 56px;
    height: 56px;
    background: var(--danger);
    border-radius: 50%;
}

.btn-stop {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: white;
    border: 4px solid var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.stop-square {
    width: 28px;
    height: 28px;
    background: var(--danger);
    border-radius: 4px;
}

.login-terms {
    color: rgba(255,255,255,0.7);
    font-size: 12px;
}

/* Role Selection */
#role-selection-screen {
    background: var(--background);
    padding: 24px;
    justify-content: center;
}

.role-container {
    text-align: center;
}

.role-container h2 {
    margin-bottom: 8px;
}

.role-container > p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.role-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.role-card {
    background: var(--surface);
    border: 2px solid transparent;
    border-radius: 16px;
    padding: 32px 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.role-card:hover, .role-card.selected {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.role-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.role-card h3 {
    font-size: 20px;
    margin-bottom: 8px;
}

.role-card p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Header */
.app-header {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    padding-top: calc(12px + var(--safe-area-top));
    box-shadow: var(--shadow);
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-small {
    font-size: 20px;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--accent);
    color: white;
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid white;
    overflow: hidden;
    cursor: pointer;
    padding: 0;
}

.avatar-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Main Content */
.app-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 80px;
}

/* Dashboard */
.dashboard {
    padding: 16px;
}

.status-bar {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.availability-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.availability-toggle span {
    font-weight: 500;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--success);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

/* Dashboard Stats */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px 8px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Dashboard Sections */
.dashboard-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.dashboard-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* Job List */
.job-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.job-card {
    background: var(--background);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}

.job-card:hover {
    border-color: var(--primary);
}

.job-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.job-card-title {
    font-weight: 600;
    font-size: 15px;
    flex: 1;
}

.job-card-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-pending { background: var(--primary-light); color: var(--primary-dark); }
.status-assigned { background: #E3F2FD; color: #1565C0; }
.status-in_progress { background: #FFF3E0; color: #E65100; }
.status-completed { background: #E8F5E9; color: #2E7D32; }
.status-cancelled { background: #FFEBEE; color: #C62828; }

.job-card-location {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.job-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.job-card-date {
    font-size: 13px;
    color: var(--text-secondary);
}

.job-card-price {
    font-weight: 600;
    color: var(--success);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 32px;
    color: var(--text-secondary);
}

/* Map Container */
.map-container {
    height: 200px;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

#cleaners-map, #job-map {
    width: 100%;
    height: 100%;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 calc(8px + var(--safe-area-bottom));
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    font-size: 22px;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: flex-end;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    width: 100%;
    max-width: 500px;
    height: 100%;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.video-modal-content {
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 10;
}

.modal-header h2 {
    font-size: 18px;
}

.close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 16px;
}

/* Video Modal */
.video-container {
    flex: 1;
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#video-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-timer {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-family: monospace;
    font-size: 18px;
}

.recording-indicator {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.recording-dot {
    width: 10px;
    height: 10px;
    background: var(--danger);
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.video-controls {
    padding: 24px;
    display: flex;
    justify-content: center;
    background: var(--surface);
}

/* Slide Panel */
.slide-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1001;
    box-shadow: -4px 0 16px rgba(0,0,0,0.15);
}

.slide-panel.active {
    transform: translateX(0);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.notifications-list {
    overflow-y: auto;
    height: calc(100% - 60px);
}

.notification-item {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.notification-item:hover {
    background: var(--background);
}

.notification-item.unread {
    background: var(--primary-light);
}

.notification-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.notification-message {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.notification-time {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--text-primary);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s;
    pointer-events: auto;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--text-primary); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateY(-20px); }
}

/* Job Detail Styles */
.job-detail-header {
    margin-bottom: 24px;
}

.job-detail-status {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.job-detail-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.job-detail-section {
    margin-bottom: 24px;
}

.job-detail-section h4 {
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.info-row {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    width: 100px;
    color: var(--text-secondary);
    font-size: 14px;
}

.info-value {
    flex: 1;
    font-size: 14px;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.action-buttons .btn {
    flex: 1;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #388E3C;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-secondary {
    background: var(--border);
    color: var(--text-primary);
}

/* Checklist */
.checklist {
    margin-top: 12px;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--background);
    border-radius: 8px;
    margin-bottom: 8px;
}

.checklist-item.completed {
    opacity: 0.6;
}

.checklist-item.completed .checklist-text {
    text-decoration: line-through;
}

.checklist-checkbox {
    width: 24px;
    height: 24px;
    accent-color: var(--primary);
}

.checklist-text {
    flex: 1;
    font-size: 14px;
}

/* Video Gallery */
.video-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.video-thumb {
    position: relative;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

.video-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-thumb-label {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Responsive */
@media (min-width: 768px) {
    .modal-content {
        max-width: 600px;
        margin: 0 auto;
        height: 90%;
        border-radius: 16px;
        margin-top: 5%;
    }
}

/* PWA Install Button */
#install-pwa {
    position: fixed;
    bottom: 80px;
    right: 16px;
    background: var(--primary);
    color: white;
    padding: 12px 20px;
    border-radius: 24px;
    border: none;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 500;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* GPS Status */
.gps-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--background);
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.gps-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    animation: gpsPulse 2s infinite;
}

.gps-indicator.inactive {
    background: var(--danger);
    animation: none;
}

@keyframes gpsPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Profile View */
.profile-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    box-shadow: var(--shadow);
}

.profile-avatar-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 16px;
    border: 3px solid var(--primary);
}

.profile-card h4 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.profile-card p {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* Map View */
#map-view .map-container {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
