/* ============================================================
   RIG ACTIVITY DASHBOARD - STYLES
   Light theme (SLB Brand), card-based, mobile-responsive
   Colors based on SLB Color Guide 2022
   ============================================================ */

:root {
    --slb-blue: #0014DB;
    --slb-aqua: #00D1DB;
    --slb-deep: #051463;
    --slb-frost1: #B0BFE0;
    --slb-frost2: #6E8CC7;
    --slb-grey1: #C7CCCC;
    --slb-grey2: #ABABAB;
    --slb-grey3: #696969;
    --bg-primary: #DCE1E1;
    --bg-secondary: #d0d5d5;
    --bg-card: #ffffff;
    --bg-card-hover: #f5f7f7;
    --bg-input: #f0f2f7;
    --bg-modal: #ffffff;
    --border: #dde0e8;
    --border-focus: #0014DB;
    --text-primary: #1a1a2e;
    --text-secondary: #555e70;
    --text-muted: #8b95a8;
    --accent: #0014DB;
    --accent-hover: #0010a0;
    --accent-light: rgba(0, 20, 219, 0.08);
    --status-drilling: #16a34a;
    --status-cementing: #6b7280;
    --status-tripping-in: #6b7280;
    --status-tripping-out: #6b7280;
    --status-running-casing: #16a34a;
    --status-logging: #6b7280;
    --status-pooh: #6b7280;
    --status-rih: #6b7280;
    --status-moving: #eab308;
    --status-run-ho: #16a34a;
    --status-npt: #dc2626;
    --status-idle-standby: #6b7280;
    --status-completing: #6b7280;
    --status-wait-on-weather: #6b7280;
    --status-p-a: #6b7280;
    --status-wow--wait-on-weather: #6b7280;
    --status-survey: #6b7280;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 2px 12px rgba(0, 20, 219, 0.06);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0b0e14 0%, #111520 50%, #0b0e14 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 32px;
    text-align: center;
    box-shadow: var(--shadow);
}

.login-logo {
    margin-bottom: 16px;
}

.login-card h1 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 24px;
}

.login-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

.login-card .form-group {
    text-align: left;
    margin-bottom: 14px;
}

.login-card label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.login-card input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.login-card input:focus {
    border-color: var(--border-focus);
}

.btn-login {
    width: 100%;
    padding: 11px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 6px;
}

.btn-login:hover {
    background: var(--accent-hover);
}

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: #0014DB;
    border-bottom: 1px solid #0014DB;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-user {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
}

.nav-role {
    font-size: 11px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.btn-icon {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    padding: 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.5);
}

.btn-logout:hover {
    border-color: #ef4444;
    color: #ef4444;
}

/* ============================================================
   TOOLBAR (Search & Filter)
   ============================================================ */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    flex: 1;
    min-width: 200px;
}

.search-box input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    width: 100%;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.filter-group select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    cursor: pointer;
}

.filter-group select:focus {
    border-color: var(--border-focus);
}

.toolbar-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.toolbar-sep {
    color: var(--border);
}

/* ============================================================
   CARDS GRID
   ============================================================ */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    padding: 20px 24px;
    max-width: 1600px;
    margin: 0 auto;
}

/* ============================================================
   RIG CARD
   ============================================================ */
.rig-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.rig-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.rig-card.dragging {
    opacity: 0.4;
    transform: scale(0.95);
    cursor: grabbing !important;
}

.rig-card.drag-over {
    border-color: #0014DB;
    border-style: dashed;
    box-shadow: 0 0 0 3px rgba(0, 20, 219, 0.2);
}

.rig-card[draggable="true"] {
    cursor: grab;
}

.rig-card[draggable="true"]:active {
    cursor: grabbing;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    background: #051464;
    border-bottom: 1px solid #051464;
    border-radius: var(--radius) var(--radius) 0 0;
}

.card-rig-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #ffffff;
}

.card-status {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* Status Colors (for status dot/indicator if used separately) */
.status-drilling { background: #16a34a; color: #ffffff; }
.status-cementing { background: #6b7280; color: #ffffff; }
.status-tripping-in { background: #6b7280; color: #ffffff; }
.status-tripping-out { background: #6b7280; color: #ffffff; }
.status-running-casing { background: #16a34a; color: #ffffff; }
.status-logging { background: #6b7280; color: #ffffff; }
.status-pooh { background: #6b7280; color: #ffffff; }
.status-rih { background: #6b7280; color: #ffffff; }
.status-moving { background: #eab308; color: #000000; }
.status-run-ho { background: #16a34a; color: #ffffff; }
.status-npt { background: #dc2626; color: #ffffff; }
.status-idle-standby { background: #6b7280; color: #ffffff; }
.status-completing { background: #6b7280; color: #ffffff; }
.status-wait-on-weather { background: #6b7280; color: #ffffff; }
.status-wow--wait-on-weather { background: #6b7280; color: #ffffff; }
.status-p-a { background: #6b7280; color: #ffffff; }
.status-survey { background: #6b7280; color: #ffffff; }

.card-body {
    padding: 12px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.field-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-value {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.4;
}

.field-multiline {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Notes expand/collapse */
.notes-content {
    font-size: 11px;
    color: var(--text-primary);
    line-height: 1.5;
    max-height: 2.8em;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    transition: max-height 0.3s ease;
    cursor: pointer;
}

.notes-expanded .notes-content {
    max-height: 500px;
}

.notes-expand-hint {
    font-size: 9px;
    font-weight: 400;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
    margin-left: 4px;
    opacity: 0.7;
}

.notes-expanded .notes-expand-hint {
    display: none;
}

.card-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #6E8CC8;
    font-size: 10px;
    color: #ffffff;
}

/* Shipment & Backload Section */
.card-shipments {
    padding: 0;
    margin: 0;
}

.shipment-block {
    padding: 8px 16px;
}

.shipment-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.shipment-value {
    display: block;
    font-size: 11px;
    color: var(--text-primary);
    margin-top: 2px;
    white-space: pre-line;
    line-height: 1.5;
}

.shipment-divider {
    height: 1px;
    background: var(--border);
    margin: 0 16px;
}

.card-updated-by {
    font-weight: 500;
    color: #ffffff;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-modal);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-sm {
    max-width: 400px;
}

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

.modal-header h2 {
    font-size: 16px;
    font-weight: 700;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.btn-close:hover {
    background: rgba(239,68,68,0.1);
    color: #ef4444;
}

.modal-body {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.modal .form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.modal .form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.modal .form-group input,
.modal .form-group select,
.modal .form-group textarea {
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
    resize: vertical;
}

.modal .form-group input:focus,
.modal .form-group select:focus,
.modal .form-group textarea:focus {
    border-color: var(--border-focus);
}

.modal .form-group select {
    cursor: pointer;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

.btn {
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    background: #22c55e;
    color: white;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
}

.toast.error {
    background: #ef4444;
}

.toast.active {
    transform: translateY(0);
    opacity: 1;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .navbar {
        padding: 10px 16px;
    }

    .nav-title {
        font-size: 14px;
    }

    .nav-user, .nav-role {
        display: none;
    }

    .toolbar {
        padding: 10px 16px;
        gap: 8px;
    }

    .search-box {
        min-width: 100%;
        order: 1;
    }

    .filter-group {
        width: 100%;
        order: 2;
    }

    .filter-group select {
        width: 100%;
    }

    .toolbar-info {
        width: 100%;
        order: 3;
        justify-content: center;
    }

    .cards-grid {
        grid-template-columns: 1fr;
        padding: 12px 16px;
        gap: 12px;
    }

    .modal {
        margin: 10px;
        max-height: 95vh;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1025px) and (max-width: 1400px) {
    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================================
   SNIPPET BADGES & PREVIEW
   ============================================================ */
.snippet-badges {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    align-items: center;
}

.snippet-badge-wrapper {
    display: inline-flex;
    align-items: center;
    position: relative;
    transition: all 0.3s;
}

.snippet-badge-wrapper:hover .snippet-delete-btn {
    opacity: 1;
}

.snippet-delete-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #dc3545;
    color: white;
    border: none;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 5;
}

.snippet-delete-btn:hover {
    background: #b02a37;
    transform: scale(1.2);
}

.revision-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 8px;
    background: rgba(0, 20, 219, 0.1);
    color: #0014DB;
    border: 1px solid rgba(0, 20, 219, 0.2);
    margin-left: 6px;
    vertical-align: middle;
    letter-spacing: 0.3px;
}

.snippet-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.snippet-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 20, 219, 0.15);
}

.snippet-badge-trajectory {
    background: rgba(0, 20, 219, 0.1);
    color: #0014DB;
}

.snippet-badge-bha {
    background: rgba(5, 20, 99, 0.1);
    color: #051463;
}

.snippet-preview {
    padding: 0 16px 12px;
}

.snippet-preview.active {
    padding-top: 8px;
}

.snippet-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    padding: 4px 0;
}

.snippet-preview-header button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}

.snippet-preview-header button:hover {
    color: #ef4444;
    background: rgba(239,68,68,0.1);
}

.snippet-preview img {
    width: 100%;
    border-radius: 6px;
    border: 1px solid var(--border);
}

/* ============================================================
   PDF UPLOAD AREA
   ============================================================ */
.card-upload {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    border-top: 1px solid #5a7ab5;
    background: #6E8CC8;
    font-size: 11px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s;
}

.card-upload:hover {
    background: #5a7ab5;
    color: #ffffff;
}

.card-upload.uploading {
    pointer-events: none;
    color: var(--accent);
}

/* Upload progress bar */
.card-upload .upload-progress {
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    animation: uploadAnim 2s ease-in-out;
}

@keyframes uploadAnim {
    0% { width: 0; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* ============================================================
   MAP SECTION
   ============================================================ */
.map-section {
    margin: 16px 24px 0;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #051464;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius) var(--radius) 0 0;
    user-select: none;
}

.map-toggle-btn {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    color: #ffffff;
    padding: 2px 6px;
}

.map-container {
    height: 300px;
    border-top: 1px solid var(--border);
}

.custom-marker {
    background: none !important;
    border: none !important;
}

/* ============================================================
   RESPONSIVE (additional)
   ============================================================ */
@media (max-width: 768px) {
    .map-section { margin: 12px 16px 0; }
    .map-container { height: 220px; }
    .snippet-badges {
        gap: 3px;
    }
    .snippet-badge {
        font-size: 9px;
        padding: 1px 6px;
    }
}

/* Hidden cards */
.rig-card.hidden {
    display: none;
}
