/* Synk PWA Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #E8655A;
    --primary-dark: #d4544a;
    --primary-light: #f5e6e4;
    --dark: #1E1E2E;
    --gray-900: #1a1a1a;
    --gray-700: #404040;
    --gray-600: #525252;
    --gray-500: #6b6b6b;
    --gray-400: #9a9a9a;
    --gray-300: #c4c4c4;
    --gray-200: #e5e5e5;
    --gray-100: #f5f5f5;
    --gray-50: #fafafa;
    --white: #ffffff;
    --green: #22c55e;
    --green-light: #dcfce7;
    --blue: #3b82f6;
    --blue-light: #dbeafe;
    --yellow: #f59e0b;
    --yellow-light: #fef3c7;
    --red: #ef4444;
    --red-light: #fee2e2;

    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.5;
}

#app {
    height: 100%;
    position: relative;
}

/* Screens */
.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    background: var(--gray-100);
}

.screen.active {
    display: flex;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: calc(12px + var(--safe-area-top));
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    min-height: 60px;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--dark);
}

.header-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--gray-100);
    border-radius: 10px;
    font-size: 1.25rem;
    cursor: pointer;
}

.back-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-700);
}

/* Login Screen */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    height: 100%;
    background: linear-gradient(180deg, var(--white) 0%, var(--gray-50) 100%);
}

.logo {
    font-size: 3rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 1.1rem;
    color: var(--gray-500);
    margin-bottom: 48px;
}

.login-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 320px;
}

.login-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.login-btn:hover, .login-btn:active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.login-icon {
    font-size: 2rem;
}

.login-text {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.login-text strong {
    font-size: 1.1rem;
    color: var(--dark);
}

.login-text small {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 320px;
    margin-top: 32px;
}

.login-form.hidden {
    display: none;
}

.pin-input {
    text-align: center;
    font-size: 2rem;
    letter-spacing: 12px;
    font-weight: 700;
}

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: space-around;
    padding: 16px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--dark);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Content */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: calc(80px + var(--safe-area-bottom));
}

.form-content {
    padding-bottom: calc(100px + var(--safe-area-bottom));
}

/* Section Headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-700);
}

.section-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-600);
}

/* Buttons */
.btn-primary {
    padding: 14px 24px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

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

.btn-primary.large {
    padding: 18px 32px;
    font-size: 1.1rem;
    width: 100%;
}

.btn-secondary {
    padding: 12px 20px;
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.btn-secondary.full-width {
    width: 100%;
}

.btn-small {
    padding: 8px 14px;
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.form-group.half {
    flex: 1;
}

.form-row {
    display: flex;
    gap: 12px;
}

.input-field {
    width: 100%;
    padding: 14px 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--gray-900);
    transition: border-color 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
}

.input-field::placeholder {
    color: var(--gray-400);
}

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

.textarea.large {
    min-height: 150px;
}

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.input-with-voice {
    position: relative;
}

.input-with-voice .input-field {
    padding-right: 50px;
}

.voice-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-100);
    border-radius: 8px;
    font-size: 1.25rem;
    cursor: pointer;
}

.voice-btn:active {
    background: var(--primary-light);
}

.input-with-voice .textarea + .voice-btn {
    top: 16px;
    transform: none;
}

.helper-text {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.form-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

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

.project-card {
    background: var(--white);
    border-radius: 16px;
    padding: 16px;
    cursor: pointer;
    border: 1px solid var(--gray-200);
    transition: all 0.2s;
}

.project-card:active {
    background: var(--gray-50);
}

.project-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 4px;
}

.project-card p {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.project-card .project-stats {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
}

.project-stats span {
    font-size: 0.8rem;
    color: var(--gray-500);
}

.project-stats strong {
    color: var(--dark);
}

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

.task-card {
    background: var(--white);
    border-radius: 16px;
    padding: 16px;
    cursor: pointer;
    border: 1px solid var(--gray-200);
    transition: all 0.2s;
}

.task-card:active {
    background: var(--gray-50);
}

.task-card.has-changes {
    border-color: var(--blue);
    background: var(--blue-light);
}

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

.task-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark);
    flex: 1;
}

.task-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.task-badge.pending {
    background: var(--yellow-light);
    color: #92400e;
}

.task-badge.in_progress {
    background: var(--blue-light);
    color: #1e40af;
}

.task-badge.completed {
    background: var(--green-light);
    color: #166534;
}

.task-badge.urgent {
    background: var(--red-light);
    color: var(--red);
}

.task-card .task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--gray-500);
}

.task-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.changes-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--blue);
    color: var(--white);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Locations List */
.locations-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.location-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: 10px;
}

.location-item span {
    font-weight: 500;
}

.location-item button {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 1.1rem;
}

/* Checklist Editor */
.checklist-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checklist-item {
    display: flex;
    gap: 8px;
    align-items: center;
}

.checklist-item input {
    flex: 1;
    padding: 10px 14px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
}

.checklist-item button {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-100);
    border-radius: 8px;
    color: var(--gray-500);
    cursor: pointer;
}

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

.worker-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    border-radius: 16px;
    padding: 16px;
    border: 1px solid var(--gray-200);
}

.worker-info h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 4px;
}

.worker-info p {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.worker-pin {
    padding: 8px 16px;
    background: var(--gray-100);
    border-radius: 8px;
    font-family: monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--dark);
}

/* Bottom Navigation */
.bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 16px;
    padding-bottom: calc(8px + var(--safe-area-bottom));
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 16px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    font-family: inherit;
}

.nav-btn span {
    font-size: 1.5rem;
}

.nav-btn small {
    font-size: 0.7rem;
    font-weight: 500;
}

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

.nav-btn.create-btn {
    width: 56px;
    height: 56px;
    background: var(--primary);
    border-radius: 50%;
    color: var(--white);
    margin-top: -20px;
    box-shadow: 0 4px 12px rgba(232, 101, 90, 0.4);
}

.nav-btn.create-btn span {
    font-size: 2rem;
    font-weight: 300;
}

/* Worker Tabs */
.worker-tabs {
    display: flex;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
}

.tab-btn {
    flex: 1;
    padding: 14px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    font-family: inherit;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Worker Task Detail */
.worker-task-detail {
    padding: 0;
}

.task-detail-header {
    background: var(--white);
    padding: 20px;
    border-radius: 0 0 24px 24px;
    margin-bottom: 16px;
}

.task-detail-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 8px;
}

.task-detail-header .project-name {
    font-size: 0.9rem;
    color: var(--gray-500);
}

.task-detail-section {
    background: var(--white);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
}

.task-detail-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.task-detail-section p {
    font-size: 1rem;
    color: var(--dark);
    line-height: 1.6;
}

.action-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--primary-light);
    border-radius: 12px;
    text-decoration: none;
    color: var(--primary);
    font-weight: 600;
    margin-top: 8px;
}

.action-link span {
    font-size: 1.25rem;
}

.checklist-view {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checklist-view-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 10px;
    cursor: pointer;
}

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

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

.check-circle {
    width: 24px;
    height: 24px;
    border: 2px solid var(--gray-300);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--white);
    flex-shrink: 0;
}

.checklist-view-item.completed .check-circle {
    background: var(--green);
    border-color: var(--green);
}

/* Worker Actions */
.worker-actions {
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-area-bottom));
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
}

.btn-complete {
    width: 100%;
    padding: 18px;
    background: var(--green);
    color: var(--white);
    border: none;
    border-radius: 14px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--white);
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.large {
    max-height: 95vh;
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    padding-bottom: calc(16px + var(--safe-area-bottom));
    border-top: 1px solid var(--gray-200);
}

/* Photo Grid */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.add-photo-btn {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: var(--gray-100);
    border: 2px dashed var(--gray-300);
    border-radius: 12px;
    cursor: pointer;
    color: var(--gray-500);
}

.add-photo-btn span {
    font-size: 1.5rem;
}

.add-photo-btn small {
    font-size: 0.75rem;
}

.photo-preview {
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-preview button {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

/* Tags Selector */
.tags-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-btn {
    padding: 10px 14px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.tag-btn.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* Voice Indicator */
.voice-indicator {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: var(--dark);
    color: var(--white);
    border-radius: 100px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    z-index: 200;
}

.voice-indicator.hidden {
    display: none;
}

.voice-pulse {
    width: 16px;
    height: 16px;
    background: var(--red);
    border-radius: 50%;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

.voice-indicator button {
    padding: 8px 16px;
    background: var(--gray-700);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-family: inherit;
    cursor: pointer;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 24px;
    background: var(--dark);
    color: var(--white);
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    z-index: 150;
    animation: slideUp 0.3s ease;
}

.toast.hidden {
    display: none;
}

.toast.success {
    background: var(--green);
}

.toast.error {
    background: var(--red);
}

@keyframes slideUp {
    from { transform: translate(-50%, 20px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-500);
}

.empty-state span {
    font-size: 3rem;
    display: block;
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 24px;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Loading */
.loading {
    display: flex;
    justify-content: center;
    padding: 48px;
}

.loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Task Detail Actions */
.task-detail-actions {
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-area-bottom));
    background: var(--white);
    border-top: 1px solid var(--gray-200);
}

/* Location Multi-Select */
.location-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.locations-select {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 12px;
    border: 1px solid var(--gray-200);
}

.location-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--white);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.location-checkbox:active {
    background: var(--gray-100);
}

.location-checkbox input {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
}

.location-checkbox span {
    flex: 1;
    font-size: 0.95rem;
}

.location-checkbox.selected {
    background: var(--primary-light);
    border: 1px solid var(--primary);
}

/* Batch Mode Toggle */
#batch-toggle.active {
    color: var(--gray-500);
}

#batch-count {
    text-align: center;
    margin-top: 8px;
    font-weight: 600;
    color: var(--primary);
}

/* Quick Actions Bar */
.quick-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    overflow-x: auto;
}

.quick-action-btn {
    flex-shrink: 0;
    padding: 8px 16px;
    background: var(--gray-100);
    border: none;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.quick-action-btn:active {
    background: var(--gray-200);
}
