/**
 * SatFinder Frontend Styles
 * Version: 4.6.1
 */

:root {
    --sf-accent: #00d4ff;
    --sf-bg: #0f172a;
    --sf-panel: #1e293b;
    --sf-warn: #fbbf24;
    --sf-err: #ff4757;
    --sf-mag: #a855f7;
    --sf-dir: #22c55e;
}

.sat-app {
    background: var(--sf-bg);
    color: #fff;
    padding: 20px;
    border-radius: 16px;
    max-width: 580px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    border: 1px solid #334155;
    margin: auto;
}

.sat-app * {
    box-sizing: border-box;
}

.sat-app input,
.sat-app select,
.sat-app textarea {
    background: var(--sf-panel);
    border: 1px solid #475569;
    color: white;
    padding: 12px;
    border-radius: 8px;
    width: 100%;
    margin-bottom: 12px;
    font-size: 14px;
}

.sat-app select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.sat-app label {
    font-size: 0.7em;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: bold;
    margin-left: 5px;
    margin-bottom: 4px;
    display: block;
}

.sf-btn {
    padding: 14px;
    border-radius: 8px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    transition: 0.2s;
    font-size: 14px;
}

.sf-btn:hover {
    opacity: 0.9;
}

/* Result Grid */
.sf-res-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-top: 15px;
}

.sf-res-item {
    background: var(--sf-panel);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #334155;
}

.sf-res-item small {
    font-size: 0.65em;
    color: #94a3b8;
    text-transform: uppercase;
    display: block;
    margin-bottom: 4px;
}

.sf-mag-row {
    grid-column: span 3;
    background: #2e1065;
    border: 1px solid var(--sf-mag);
    padding: 12px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

/* Extra Panels */
.sf-extra-panel {
    background: var(--sf-panel);
    padding: 12px;
    border-radius: 8px;
    margin-top: 10px;
    border: 1px solid #334155;
}

/* Compass Dials */
.sf-dial-row {
    display: flex;
    justify-content: space-around;
    margin: 15px 0;
    gap: 10px;
}

.sf-dial-container {
    text-align: center;
    flex: 1;
}

.sf-compass-box {
    position: relative;
    width: 115px;
    height: 115px;
    border: 4px solid var(--sf-panel);
    border-radius: 50%;
    background: #020617;
    margin: auto;
}

#sf-needle,
#sf-skew-needle {
    position: absolute;
    top: 10%;
    left: 50%;
    width: 4px;
    height: 40%;
    background: var(--sf-accent);
    transform-origin: bottom center;
    transition: transform 0.8s;
    border-radius: 4px;
    z-index: 2;
    margin-left: -2px;
}

#sf-skew-needle {
    background: var(--sf-warn);
}

/* Mini Map - Legacy (now using dual maps) */
#sf-mini-map-container {
    display: none; /* Replaced by dual maps */
}

/* Responsive - Dual Maps Stack */
@media (max-width: 600px) {
    .sf-res-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .sf-mag-row {
        grid-column: span 2;
    }
    
    .sf-modal-body {
        padding: 15px;
    }
    
    .sf-sat-map {
        height: 180px;
    }
    
    .sf-photo-grid-new {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Auth Section */
.sf-auth-section {
    background: var(--sf-panel);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #334155;
}

.sf-auth-section.logged-in {
    background: #1a3a1a;
    border-color: var(--sf-dir);
}

.sf-auth-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.sf-auth-row input {
    margin-bottom: 0;
    flex: 1;
}

.sf-user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Body scroll lock when modal is open */
body.sf-modal-open {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Modal - FIXED for scrolling - header always visible */
.sf-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 99999;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sf-modal-overlay.active {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.sf-modal {
    background: var(--sf-bg);
    border: 1px solid #334155;
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    margin: 20px auto;
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 40px);
    /* Prevent clicks inside modal from closing it */
    pointer-events: auto;
}

.sf-modal-header {
    padding: 20px;
    border-bottom: 1px solid #334155;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--sf-bg);
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

.sf-modal-header h3 {
    margin: 0;
    color: var(--sf-accent);
}

.sf-modal-close {
    background: #7f1d1d;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.sf-modal-close:hover {
    background: #991b1b;
}

.sf-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Event List */
.sf-event-list {
    max-height: 300px;
    overflow-y: auto;
}

.sf-event-item {
    background: var(--sf-panel);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid #334155;
    cursor: pointer;
}

.sf-event-item:hover {
    border-color: var(--sf-accent);
}

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

.sf-photo-item {
    position: relative;
}

.sf-photo-grid img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
}

/* New Photo Grid with Delete Below */
.sf-photo-grid-new {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.sf-photo-item-new {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.sf-photo-item-new img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid #334155;
}

.sf-photo-delete-btn {
    background: #7f1d1d;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 8px;
    cursor: pointer;
    font-size: 12px;
    width: 100%;
    transition: background 0.2s;
}

.sf-photo-delete-btn:hover {
    background: #991b1b;
}

.sf-photo-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #7f1d1d;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sf-photo-delete:hover {
    background: #991b1b;
}

/* Dual Satellite Maps */
.sf-sat-map {
    height: 220px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #334155;
    position: relative;
}

.sf-map-container {
    background: var(--sf-panel);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #334155;
}

/* Custom arrow icon for maps */
.direction-arrow-custom {
    background: transparent !important;
    border: none !important;
}

.sf-map-info {
    text-align: center;
    font-size: 0.85em;
    color: #94a3b8;
    margin-top: 8px;
    padding: 5px;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
}

.sf-map-north-indicator {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(15, 23, 42, 0.9);
    color: var(--sf-err);
    font-weight: bold;
    font-size: 14px;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--sf-err);
}

/* Controller Image */
.sf-controller-section {
    background: var(--sf-panel);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #334155;
}

/* Averaged Panel */
.sf-averaged-panel {
    background: #1a2236;
    border: 1px solid var(--sf-warn);
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    display: none;
}

.sf-averaged-panel h4 {
    color: var(--sf-warn);
    margin: 0 0 10px 0;
}

/* Solar Card */
.sf-solar-card {
    background: #1a2236;
    border-left: 4px solid var(--sf-warn);
    padding: 12px;
    border-radius: 8px;
    margin-top: 15px;
    font-size: 0.85em;
}

.sf-outage-alert {
    color: var(--sf-err);
    font-weight: bold;
    animation: sf-blink 1.5s infinite;
}

@keyframes sf-blink {
    50% { opacity: 0.4; }
}

/* Warning */
.sf-warning {
    color: var(--sf-err);
    text-align: center;
    margin-top: 10px;
}

/* Version Tag */
.sf-version-tag {
    font-size: 0.6em;
    color: #475569;
    text-align: center;
    margin-top: 15px;
}

/* Copy Button */
.sf-copy-btn {
    cursor: pointer;
    color: var(--sf-accent);
    margin-left: 5px;
}

/* Form Section in Modal */
.sf-form-section {
    background: var(--sf-panel);
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    border: 1px solid #334155;
}

.sf-form-section h4 {
    color: var(--sf-warn);
    margin: 0 0 15px 0;
}

.sf-form-section h5 {
    color: #94a3b8;
    margin: 15px 0 10px 0;
    font-size: 0.85em;
}

/* Canvas */
#sf-az-arc {
    width: 100%;
    height: 80px;
    margin-top: 10px;
}
