/**
 * ==========================================================================
 * WILDLIFE RESCUE LINK — GOOGLE SHEETS SPREADSHEET STYLING (editable_grid.css)
 * Component: editable_grid.css (v0.060l)
 * Features:
 * - Content-aware auto-width columns with double-click auto-fit & drag resizing
 * - Drag-up / Swipe-up Bottom Drawer Card for full row viewing & multi-field editing
 * - Google Sheets 2D cell navigation, inline editors, formula bar, status pills
 * ==========================================================================
 */

.gs-spreadsheet-container {
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #f3f4f6;
    position: relative;
}

.gs-sheet-panel {
    display: flex;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
    position: relative;
}

/* Toolbar Styles */
.gs-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(10, 15, 29, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.gs-toolbar-row-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.gs-title-badge {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gs-sheet-icon {
    font-size: 18px;
}

.gs-title-text {
    font-size: 15px;
    font-weight: 700;
    color: #f9fafb;
    letter-spacing: -0.01em;
}

.gs-org-pill {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.gs-count-badge {
    font-size: 12px;
    color: #9ca3af;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.gs-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gs-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    border: 1px solid transparent;
}

.gs-btn-primary {
    background: #0284c7;
    color: #ffffff;
    border-color: rgba(56, 189, 248, 0.3);
}
.gs-btn-primary:hover {
    background: #0369a1;
}

.gs-btn-success {
    background: #10b981;
    color: #ffffff;
    border-color: rgba(52, 211, 153, 0.3);
}
.gs-btn-success:hover {
    background: #059669;
}

.gs-btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: #e5e7eb;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.gs-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Filters Row */
.gs-toolbar-row-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.gs-search-box {
    position: relative;
    flex: 1;
    min-width: 220px;
}

.gs-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    pointer-events: none;
}

.gs-search-input {
    width: 100%;
    padding: 6px 10px 6px 32px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #f9fafb;
    font-size: 12px;
    outline: none;
    box-sizing: border-box;
}
.gs-search-input:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.gs-select {
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #f3f4f6;
    font-size: 12px;
    outline: none;
    cursor: pointer;
}
.gs-select option {
    background: #0f172a;
    color: #f9fafb;
}

/* Checkbox Pill Control */
.gs-checkbox-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    color: #e2e8f0;
    transition: all 0.15s ease-in-out;
}
.gs-checkbox-pill:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(56, 189, 248, 0.3);
}
.gs-checkbox-pill input[type="checkbox"] {
    accent-color: #10b981;
    width: 14px;
    height: 14px;
    cursor: pointer;
    margin: 0;
}
.gs-checkbox-text {
    font-weight: 600;
    font-size: 11.5px;
    letter-spacing: 0.01em;
}

/* Formula Bar */
.gs-formula-bar {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
}

.gs-cell-name-box {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.08);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 48px;
    text-align: center;
    font-family: monospace;
}

.gs-fx-symbol {
    padding: 6px 10px;
    font-style: italic;
    font-weight: 700;
    color: #9ca3af;
    font-size: 13px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    user-select: none;
}

.gs-formula-input {
    flex: 1;
    padding: 6px 12px;
    background: transparent;
    border: none;
    color: #f9fafb;
    font-size: 12px;
    outline: none;
    font-family: inherit;
}
.gs-formula-input:focus {
    background: rgba(255, 255, 255, 0.03);
}

/* Spreadsheet Viewport */
.gs-viewport {
    position: relative;
    max-height: calc(100vh - 300px);
    min-height: 400px;
    overflow: auto;
    background: #0a0e17;
    outline: none;
}

.gs-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    user-select: none;
}

/* Header Row & Sticky Column Letters */
.gs-header-row {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #111827;
}

.gs-col-corner {
    position: sticky;
    left: 0;
    top: 0;
    z-index: 20;
    width: 38px;
    min-width: 38px;
    background: #1e293b;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    color: #94a3b8;
    font-weight: 700;
    text-align: center;
    padding: 6px 4px;
}

.gs-col-header {
    background: #1e293b;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    padding: 6px 8px;
    text-align: left;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: background 0.1s;
}
.gs-col-header:hover {
    background: #273549;
}

.gs-col-header-inner {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 8px;
}

.gs-col-letter {
    color: #38bdf8;
    font-weight: 700;
    font-size: 11px;
    font-family: monospace;
}

.gs-col-title {
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gs-sort-indicator {
    font-size: 10px;
    color: #10b981;
    margin-left: auto;
}

/* Column Resizer Handle */
.gs-col-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    z-index: 12;
}
.gs-col-resizer:hover,
.gs-resizer-active {
    background: #38bdf8 !important;
    box-shadow: 0 0 6px #38bdf8;
}

/* Row Numbers Gutter */
.gs-row-header {
    position: sticky;
    left: 0;
    z-index: 5;
    background: #1e293b;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    color: #94a3b8;
    font-weight: 600;
    text-align: center;
    font-size: 11px;
    font-family: monospace;
    padding: 4px 6px;
    width: 38px;
    min-width: 38px;
    cursor: pointer;
}
.gs-row-header:hover {
    background: #334155;
    color: #f1f5f9;
}

/* Active Row/Col Headers */
.gs-header-active {
    background: #0284c7 !important;
    color: #ffffff !important;
}
.gs-header-active .gs-col-letter {
    color: #ffffff !important;
}

/* Data Cells */
.gs-cell {
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0;
    height: 28px;
    max-height: 28px;
    background: #0b111e;
    color: #f1f5f9;
    position: relative;
    cursor: cell;
}

.gs-row:hover .gs-cell {
    background: #0f182a;
}

.gs-cell-content {
    padding: 3px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    font-size: 11.5px;
}

/* Active Selected Cell */
.gs-cell-active {
    outline: 2px solid #10b981 !important;
    outline-offset: -2px;
    background: rgba(16, 185, 129, 0.12) !important;
    z-index: 2;
}

.gs-cell-active::after {
    content: '';
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 6px;
    height: 6px;
    background: #10b981;
    border: 1px solid #ffffff;
    z-index: 3;
    pointer-events: none;
}

/* Dirty (Modified) & Saving Cells */
.gs-cell-dirty {
    background: rgba(245, 158, 11, 0.1) !important;
}
.gs-cell-dirty::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    border-style: solid;
    border-width: 0 6px 6px 0;
    border-color: transparent #f59e0b transparent transparent;
    z-index: 1;
}

.gs-cell-saving {
    opacity: 0.6;
    background: rgba(59, 130, 246, 0.15) !important;
}

/* Inline Cell Editors */
.gs-inline-input {
    width: 100%;
    height: 100%;
    padding: 2px 6px;
    border: none;
    outline: none;
    background: #ffffff;
    color: #0f172a;
    font-size: 11.5px;
    font-family: inherit;
    box-sizing: border-box;
}

.gs-inline-select {
    width: 100%;
    height: 100%;
    padding: 0 4px;
    border: none;
    outline: none;
    background: #1e293b;
    color: #ffffff;
    font-size: 11.5px;
    font-family: inherit;
    box-sizing: border-box;
}

/* Badges & Tags */
.gs-status-pill {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.gs-status-in-care { background: rgba(56, 189, 248, 0.2); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.3); }
.gs-status-released { background: rgba(52, 211, 153, 0.2); color: #34d399; border: 1px solid rgba(52, 211, 153, 0.3); }
.gs-status-reported { background: rgba(251, 191, 36, 0.2); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.3); }
.gs-status-wildlife-hosp, .gs-status-vet { background: rgba(168, 85, 247, 0.2); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.gs-status-deceased { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }

.gs-endemic-tag {
    color: #fbbf24;
    font-weight: 700;
    font-size: 11px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.gs-native-tag {
    color: #34d399;
    font-weight: 600;
    font-size: 11px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
.gs-non-native-tag {
    color: #94a3b8;
    font-size: 11px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.gs-image-link {
    color: #38bdf8;
    text-decoration: underline;
    font-size: 11px;
}

/* Status Bar */
.gs-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 16px;
    background: rgba(10, 15, 29, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 11px;
    color: #94a3b8;
}

.gs-drawer-peek-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(56, 189, 248, 0.1);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.gs-drawer-peek-btn:hover {
    background: rgba(56, 189, 248, 0.2);
}

.gs-dirty-badge {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    margin-left: 8px;
}

.gs-spinner {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #38bdf8;
    border-radius: 50%;
    animation: gsSpin 0.6s linear infinite;
}

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

/* ==========================================================================
 * DRAG-UP / SWIPE-UP BOTTOM DRAWER CARD STYLING
 * ========================================================================== */

.gs-bottom-drawer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.6);
    z-index: 100;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), height 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Drawer States */
.gs-drawer-closed {
    transform: translateY(100%);
    height: 0;
}

.gs-drawer-half {
    transform: translateY(0);
    height: 52vh;
}

.gs-drawer-full {
    transform: translateY(0);
    height: 85vh;
}

/* Drawer Handle Bar */
.gs-drawer-handle-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: rgba(2, 6, 23, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    cursor: grab;
    user-select: none;
    position: relative;
}
.gs-drawer-handle-bar:active {
    cursor: grabbing;
}

.gs-drag-pill {
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.3);
}

.gs-drawer-header-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.gs-drawer-title-icon {
    font-size: 15px;
}

.gs-drawer-title {
    font-size: 13px;
    font-weight: 700;
    color: #f9fafb;
}

.gs-drawer-status-pill {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.gs-drawer-header-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.gs-drawer-control-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.gs-drawer-control-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

/* Drawer Form Body */
.gs-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.gs-drawer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.gs-card-box {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.gs-card-title {
    font-size: 12px;
    font-weight: 700;
    color: #38bdf8;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 6px;
}

.gs-field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gs-field-group label {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
}

.gs-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.gs-input, .gs-textarea {
    width: 100%;
    padding: 6px 10px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: #f9fafb;
    font-size: 12px;
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
}
.gs-input:focus, .gs-textarea:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}
.gs-input[readonly] {
    opacity: 0.6;
    cursor: not-allowed;
    background: rgba(0, 0, 0, 0.2);
}

.gs-input-with-action {
    display: flex;
    gap: 6px;
}
.gs-input-action-btn {
    padding: 4px 8px;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.3);
    color: #38bdf8;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}
.gs-input-action-btn:hover {
    background: rgba(56, 189, 248, 0.25);
}

.gs-drawer-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
    padding-top: 10px;
}

@media (max-width: 768px) {
    .gs-toolbar-row-top {
        flex-direction: column;
        align-items: stretch;
    }
    .gs-toolbar-actions {
        justify-content: space-between;
    }
    .gs-viewport {
        max-height: calc(100vh - 360px);
    }
    .gs-drawer-half {
        height: 65vh;
    }
    .gs-drawer-grid {
        grid-template-columns: 1fr;
    }
}
