/* ============================================
   TADAL Picture - Mobile-First Styles
   ============================================ */

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --success: #34a853;
    --danger: #ea4335;
    --warning: #fbbc04;
    --info: #4285f4;
    --bg-light: #f8f9fa;
    --text-muted: #6c757d;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,.1);
    --radius: 12px;
    --radius-sm: 8px;
}

/* Base */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-light);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

/* Navbar */
.navbar {
    box-shadow: var(--shadow-sm);
    z-index: 1030;
}

.navbar-brand {
    font-size: 1.1rem;
}

/* Cards */
.card {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-hover:active {
    transform: scale(0.98);
    transition: transform 0.1s;
}

/* Visit Card */
.visit-card {
    cursor: pointer;
    transition: box-shadow 0.2s;
    margin-bottom: 12px;
}

.visit-card:hover {
    box-shadow: var(--shadow-md);
}

.visit-card .card-body {
    padding: 12px 16px;
}

.visit-card .client-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 4px;
}

.visit-card .visit-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.visit-card .photo-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Status badges */
.badge-status {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-in_progress { background: var(--warning); color: #333; }
.badge-submitted { background: var(--info); color: #fff; }
.badge-validated { background: var(--success); color: #fff; }
.badge-invalidated { background: var(--danger); color: #fff; }

/* Date navigation */
.date-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    margin-bottom: 16px;
}

.date-nav .date-label {
    font-weight: 600;
    font-size: 1rem;
    text-align: center;
}

.date-nav .date-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.date-nav .btn {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(26,115,232,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 1000;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
}

.fab:hover, .fab:active {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(26,115,232,.5);
    color: white;
}

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

.photo-grid .photo-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #e9ecef;
    cursor: pointer;
}

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

.photo-grid .photo-item .photo-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(234,67,53,.9);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    z-index: 2;
}

.photo-grid .photo-item .photo-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 10px;
    background: rgba(0,0,0,.6);
    color: white;
}

.photo-grid .photo-item .validation-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.validation-badge.valid { background: var(--success); color: white; }
.validation-badge.invalid { background: var(--danger); color: white; }

/* Photo add button */
.photo-add {
    aspect-ratio: 1;
    border: 2px dashed #ced4da;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: border-color 0.2s;
    min-height: 100px;
}

.photo-add:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.photo-add svg {
    width: 32px;
    height: 32px;
    margin-bottom: 4px;
}

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

/* Photo strip (horizontal scroll) */
.photo-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
}

.photo-strip .photo-item {
    flex: 0 0 auto;
    width: 100px;
    height: 100px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    scroll-snap-align: start;
}

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

/* Wizard steps */
.wizard-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 0;
    list-style: none;
    counter-reset: step;
}

.wizard-steps li {
    flex: 1;
    text-align: center;
    position: relative;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.wizard-steps li::before {
    counter-increment: step;
    content: counter(step);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: 0 auto 4px;
    border-radius: 50%;
    background: #e9ecef;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
}

.wizard-steps li.active::before {
    background: var(--primary);
    color: white;
}

.wizard-steps li.completed::before {
    background: var(--success);
    color: white;
    content: '\2713';
}

.wizard-steps li.active {
    color: var(--primary);
    font-weight: 600;
}

.wizard-steps li:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 16px;
    left: calc(50% + 20px);
    width: calc(100% - 40px);
    height: 2px;
    background: #e9ecef;
}

.wizard-steps li.completed:not(:last-child)::after {
    background: var(--success);
}

/* Wizard panels */
.wizard-panel {
    display: none;
}

.wizard-panel.active {
    display: block;
}

/* Stat cards (admin) */
.stat-card {
    text-align: center;
    padding: 16px 8px;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Admin filters */
.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-bar .form-select,
.filter-bar .form-control {
    flex: 1;
    min-width: 120px;
    font-size: 0.85rem;
}

/* Remark card */
.remark-card {
    background: #fff3cd;
    border-left: 4px solid var(--warning);
    padding: 12px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 8px;
}

.remark-card .remark-author {
    font-weight: 600;
    font-size: 0.85rem;
}

.remark-card .remark-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.remark-card .remark-text {
    margin-top: 4px;
    font-size: 0.9rem;
}

/* Map marker / GPS */
.gps-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: #e8f0fe;
    margin-bottom: 12px;
}

.gps-status.error {
    background: #fce8e6;
}

.gps-status.success {
    background: #e6f4ea;
}

/* Lightbox */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-overlay img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,.2);
    border: none;
    color: white;
    border-radius: 50%;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Forms */
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(26,115,232,.25);
}

/* Touch-friendly buttons */
.btn {
    min-height: 44px;
    border-radius: var(--radius-sm);
}

.btn-sm {
    min-height: 36px;
}

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

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    margin-bottom: 16px;
}

/* Loading spinner overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,.8);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Photo upload progress */
.upload-progress {
    position: relative;
}

.upload-progress .progress {
    height: 4px;
    border-radius: 2px;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
}

/* Info row in visit detail */
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
}

.info-row .info-label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.info-row .info-value {
    font-weight: 500;
    text-align: right;
}

/* Section titles */
.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin: 24px 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
}

/* Tablet+ responsive */
@media (min-width: 768px) {
    .photo-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .stat-card .stat-value {
        font-size: 2rem;
    }
}

@media (min-width: 992px) {
    .photo-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* PWA install banner */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 12px 16px;
    box-shadow: 0 -2px 10px rgba(0,0,0,.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1050;
}

/* User table in admin */
.user-table td, .user-table th {
    vertical-align: middle;
    font-size: 0.9rem;
}

/* Scrollbar hiding for horizontal strips */
.photo-strip::-webkit-scrollbar {
    display: none;
}

.photo-strip {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
