/* ============================================
   Aiforsite Drones — Global Styles
   ============================================ */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --navbar-height: 56px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.5;
}

/* ---- Navbar ---- */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--navbar-height);
    padding: 0 24px;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-weight: 700;
    font-size: 18px;
    color: var(--gray-900);
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-user {
    font-size: 14px;
    color: var(--gray-600);
}

.nav-link {
    font-size: 14px;
    color: var(--gray-500);
    text-decoration: none;
}
.nav-link:hover { color: var(--gray-800); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: white;
    color: var(--gray-700);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}
.btn:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

.btn-secondary { background: var(--gray-100); }

.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

.btn-full { width: 100%; }

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 4px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--gray-800);
    background: white;
    transition: border-color 0.15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.error-msg {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 14px;
    margin-bottom: 16px;
}

/* ---- Auth pages ---- */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--navbar-height));
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
}

.auth-logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    margin-bottom: 8px;
}

.auth-card h1 {
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 24px;
    color: var(--gray-800);
}

.auth-link {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--gray-500);
}
.auth-link a { color: var(--primary); text-decoration: none; }
.auth-link a:hover { text-decoration: underline; }

/* ---- Dashboard ---- */
.dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

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

.dashboard-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.project-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s, transform 0.2s;
}
.project-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.project-card-map {
    height: 160px;
    background: var(--gray-100);
}

.project-card-body {
    padding: 16px;
}

.project-card-body h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.project-location {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.project-desc {
    font-size: 13px;
    color: var(--gray-600);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-meta {
    font-size: 12px;
    color: var(--gray-400);
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 80px 24px;
}

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

.empty-state h2 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--gray-700);
}

.empty-state p {
    color: var(--gray-500);
    margin-bottom: 24px;
}

/* ---- Modal ---- */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    font-size: 18px;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-uploading { background: #fef3c7; color: #92400e; }
.badge-uploaded { background: #dbeafe; color: #1e40af; }
.badge-queued { background: #e0e7ff; color: #3730a3; }
.badge-processing { background: #fef3c7; color: #92400e; }
.badge-completed { background: #dcfce7; color: #166534; }
.badge-failed { background: #fef2f2; color: #991b1b; }

/* ---- Project layout (map view) ---- */
.project-layout {
    display: flex;
    height: calc(100vh - var(--navbar-height));
}

.sidebar {
    width: 320px;
    background: white;
    border-right: 1px solid var(--gray-200);
    padding: 20px;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.sidebar h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 20px 0 8px;
}

.map-area {
    flex: 1;
    position: relative;
}

/* ---- Flight cards ---- */
.flight-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.15s;
}
.flight-card:hover { background: var(--gray-50); }
.flight-card.active { border-color: var(--primary); background: var(--primary-light); }

/* ---- Layer switcher ---- */
.layer-switcher {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 1000;
    display: flex;
    gap: 4px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 4px;
}

.layer-switcher button {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
}
.layer-switcher button.active {
    background: var(--primary);
    color: white;
}

/* ---- Measure tools ---- */
.measure-tools {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 4px;
}

.measure-tools button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.measure-tools button:hover { background: var(--gray-100); }
.measure-tools button.active { background: var(--primary-light); }

/* ---- View switcher (2D / PointCloud / Mesh) ---- */
.view-switcher {
    position: absolute;
    top: 12px;
    right: 60px;
    z-index: 1000;
    display: flex;
    gap: 4px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 4px;
}

.view-switcher button {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
}
.view-switcher button.active {
    background: var(--primary);
    color: white;
}

/* ---- Elevation profile panel ---- */
.elevation-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1001;
    background: white;
    border-top: 1px solid var(--gray-200);
    box-shadow: 0 -4px 6px rgba(0,0,0,0.1);
    padding: 12px 16px;
}

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

.elevation-header h4 {
    font-size: 14px;
    font-weight: 600;
}

.elevation-stats {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 8px;
    text-align: center;
}

#elevation-canvas {
    width: 100%;
    height: 150px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

/* ---- Sidebar details ---- */
.sidebar-header {
    margin-bottom: 20px;
}

.back-link {
    font-size: 13px;
    color: var(--gray-500);
    text-decoration: none;
    display: inline-block;
    margin-bottom: 8px;
}
.back-link:hover { color: var(--primary); }

.sidebar-section {
    margin-bottom: 20px;
}

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

.sidebar-empty {
    font-size: 13px;
    color: var(--gray-400);
    text-align: center;
    padding: 12px;
}

.flight-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.flight-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flight-meta {
    font-size: 12px;
    color: var(--gray-400);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* ---- Drop zone ---- */
.drop-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 16px;
}
.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.drop-zone-content p {
    margin: 8px 0 0;
    color: var(--gray-600);
}

.drop-zone-hint {
    font-size: 13px;
    color: var(--gray-400) !important;
}

.link-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: inherit;
    text-decoration: underline;
}

.modal-lg { max-width: 640px; }

/* ---- File list ---- */
.file-list {
    margin-bottom: 16px;
}

.file-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--gray-600);
}

.file-items {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    font-size: 13px;
    border-bottom: 1px solid var(--gray-100);
}
.file-item:last-child { border-bottom: none; }

.file-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item-size {
    color: var(--gray-400);
    margin-left: 8px;
    flex-shrink: 0;
}

.file-item-status {
    margin-left: 8px;
    flex-shrink: 0;
}

.file-item-status.done { color: var(--success); }
.file-item-status.error { color: var(--danger); }
.file-item-status.uploading { color: var(--warning); }

/* ---- Progress bar ---- */
.progress-bar {
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-lg {
    height: 10px;
    border-radius: 5px;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: inherit;
    transition: width 0.3s ease;
}

.upload-status {
    text-align: center;
    font-size: 14px;
    color: var(--gray-600);
    margin-top: 8px;
}

.progress-text {
    font-size: 13px;
    color: var(--gray-500);
}

/* ---- Processing overlay ---- */
.processing-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.processing-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    text-align: center;
    width: 320px;
}

.processing-card h3 {
    margin: 16px 0 8px;
    font-size: 16px;
}

.processing-card p {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 16px;
}

.processing-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* ---- Annotation list ---- */
.annotation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 6px;
    font-size: 13px;
    cursor: pointer;
}
.annotation-item:hover { background: var(--gray-50); }

.annotation-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    margin-right: 8px;
    flex-shrink: 0;
}

.annotation-info {
    flex: 1;
    min-width: 0;
}

.annotation-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.annotation-value {
    font-size: 12px;
    color: var(--gray-500);
}

/* ---- Settings page ---- */
.settings-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

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

.settings-card-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.settings-meta {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 2px;
}

.members-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.member-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.member-name {
    font-size: 14px;
    font-weight: 500;
}

.member-email {
    font-size: 12px;
    color: var(--gray-400);
}

.badge-role {
    background: var(--primary-light);
    color: var(--primary);
}

.form-input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--gray-800);
    background: white;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.invite-msg {
    font-size: 13px;
    padding: 6px 10px;
    border-radius: var(--radius);
}
.invite-msg.success {
    background: #dcfce7;
    color: #166534;
}
.invite-msg.error {
    background: #fef2f2;
    color: #991b1b;
}

/* Export / download list */
.export-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.export-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 13px;
}

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

.export-item-icon {
    font-size: 16px;
}

.export-item-name {
    font-weight: 500;
}

.export-item-size {
    font-size: 11px;
    color: var(--gray-400);
}

/* Embed tokens section */
.embed-tokens-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.embed-token-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 13px;
}

.embed-token-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.embed-token-domains {
    font-size: 12px;
    color: var(--gray-400);
}

.token-display {
    font-family: monospace;
    font-size: 12px;
    background: var(--gray-100);
    padding: 8px 12px;
    border-radius: var(--radius);
    word-break: break-all;
    margin-top: 8px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .project-layout {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
    }
    .project-grid {
        grid-template-columns: 1fr;
    }
    .dashboard {
        padding: 16px;
    }
}
