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

html, body {
    height: 100%;
    margin: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(#e7f2ff, #d5e6f9);
    color: #222;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 1.8rem;
    font-weight: 300;
}

/* Control panel */
.controls {
    display: flex;
    gap: 2rem;
    padding: 1rem;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    flex-wrap: wrap;
}

/* Ribbon bar styled like Windows 7 */
.ribbon {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 8px;
    background: linear-gradient(to bottom, #fdfdff, #c6d6ec);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7), 0 1px 4px rgba(0,0,0,0.3);
    z-index: 1000;
}

.ribbon label {
    margin-right: 4px;
    font-weight: 600;
    font-size: 14px;
}

.ribbon input,
.ribbon select,
.ribbon button {
    margin-right: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    border: 1px solid #7f9db9;
    background: linear-gradient(#ffffff, #e8f0fa);
    font-size: 14px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.ribbon button:hover {
    background: linear-gradient(#e8f0fa, #dbe7f7);
}

.ribbon button.primary {
    color: #fff;
    outline: solid 1px #005a9e;
    border-color: #005a9e;
    background: linear-gradient(#3aa0f5, #0078d7);
}

.ribbon button.primary:hover {
    background: linear-gradient(#51a9f5, #1084d8);
}

.ribbon button.primary:active {
    background: linear-gradient(#005a9e, #006fc7);
    box-shadow: inset 0 0 0 1px #003f7f;
}

.search-section {
    flex: 1;
    min-width: 300px;
}

.search-section h3 {
    margin-bottom: 0.5rem;
    color: #4a5568;
    font-weight: 500;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.input-group label {
    font-weight: 500;
    min-width: 120px;
}

input[type="text"], select {
    flex: 1;
    padding: 0.5rem;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

input[type="text"]:focus, select:focus {
    outline: none;
    border-color: #667eea;
}

/* Buttons styled like Windows 7 */
button {
    border: none;
    outline: solid 1px #757575;
    box-shadow: inset 0 0 0 1px #fcfcfc;
    color: black;
    padding: 3px 12px;
    background: linear-gradient(0deg, #cfcfcf 0%, #dbdbdb 49%, #ebebeb 49%, #fcfcfc 100%);
    border-radius: 3px;
    font-size: 14px;
    cursor: pointer;
}

button:hover {
    outline: solid 1px #3c7fb1;
    background: linear-gradient(0deg, #a7d9f5 0%, #bce5fc 49%, #d9f0fc 49%, #eaf6fd 100%);
}

button:active {
    outline: solid 1px #2c628b;
    background: linear-gradient(0deg, #68b2da 0%, #98d1ef 49%, #c4e5f6 49%, #e5f4fc 100%);
    box-shadow: inset 0 0 0 2px #86c6e8;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.button-group {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Form elements */
#coords-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin: 0;
}

#search-input {
    min-width: 150px;
}

#search-container {
    position: relative;
}

#search-suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #7f9db9;
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
}

#search-suggestions-list .suggestion-item {
    padding: 4px 6px;
    cursor: pointer;
}

#search-suggestions-list .suggestion-item:hover {
    background: #e8f0fa;
}

.hidden {
    display: none;
}

/* Coordinate display */
.coords-display {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.25rem;
}

/* Main content */
.main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* Map */
#map {
    width: 100%;
    height: 100%;
    flex: 1;
}

/* Status */
#status {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.8);
    padding: 6px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    display: none;
    z-index: 1000;
}

#loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    color: #fff;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 2000;
}

.spinner {
    width: 64px;
    height: 64px;
    background: url('/static/images/Spinner.png') no-repeat center center;
    background-size: contain;
    margin-bottom: 1rem;
    animation: spin 1s linear infinite;
}

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

.status-hidden {
    opacity: 0;
    pointer-events: none;
}

.status-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#status-text {
    font-weight: 500;
    font-size: 0.9rem;
}

/* Progress bar */
#progress-bar {
    width: 200px;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
    transition: opacity 0.3s;
}

.progress-hidden {
    opacity: 0;
}

#progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
}

/* Modal window */
.modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}


.modal-content {
    position: relative;
    background: linear-gradient(#fdfdff, #c6d6ec);
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    max-width: 98vw;
    max-height: 98vh;
    padding: 1rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4), inset 0 0 0 1px #fcfcfc;
    border: 1px solid #7f9db9;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.close {
    position: absolute;
    top: -8px;
    right: -1px;
    width: 24px;
    height: 24px;
    background: url('/static/images/winclose.png') no-repeat center center;
    background-size: contain;
    cursor: pointer;
    z-index: 2001;
    border: none;
}


.author-btn {
    width: 24px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.author-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.author-btn:hover {
    transform: scale(1.1);
}

.close:hover {
    transform: scale(1.1);
}


#modal-image-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#modal-progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(0,0,0,0.1);
    overflow: hidden;
    z-index: 20;
}

#modal-progress-bar {
    height: 100%;
    width: 0;
    background:
        repeating-linear-gradient(-45deg, rgba(255,255,255,0.4) 0, rgba(255,255,255,0.4) 10px, rgba(255,255,255,0) 10px, rgba(255,255,255,0) 20px),
        linear-gradient(to bottom, rgba(255,255,255,0.6), rgba(255,255,255,0.2) 50%, rgba(0,0,0,0.2) 51%, rgba(0,0,0,0.3)),
        linear-gradient(to bottom, #c4f1a4 0%, #7bd43a 50%, #4ca71a 100%);
    background-size: 40px 40px, 100% 100%, 100% 100%;
    animation: progressStripes 1s linear infinite;
    box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 -1px 0 rgba(0,0,0,0.2) inset;
}

@keyframes progressStripes {
    from { background-position: 0 0, 0 0, 0 0; }
    to { background-position: 40px 0, 0 0, 0 0; }
}

#modal-image {
    width: auto;
    height: auto;
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 5px;
    border: 2px solid rgba(255,255,255,0.95);
    background: #f6faff;
    box-shadow: 0 0 1px rgba(255,255,255,0.6) inset, 0 0 12px rgba(0,0,0,0.6);
}

#modal-info {
    margin-top: 0.5rem;
    max-height: 20vh;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.author-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.author-buttons {
    display: flex;
    gap: 0.25rem;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    width: 98%;
    max-width: 98%;
}

.tag-badge {
    background: linear-gradient(0deg, #ffffff 0%, #e4eef9 49%, #cbdff7 100%);
    border: 1px solid #7f9db9;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 0.75rem;
    color: #000;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
    overflow-wrap: anywhere;
    max-width: 100%;
    cursor: pointer;
}

.photo-info {
    padding: 1.5rem;
    background: white;
}

.photo-info h3 {
    margin-bottom: 1rem;
    color: #2d3748;
}

.photo-info p {
    margin-bottom: 0.5rem;
    color: #4a5568;
}

/* Author link as regular text */
#modal-info h3 a {
    color: inherit;
    text-decoration: none;
}

#modal-profile {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

#modal-profile:hover {
    text-decoration: underline;
}

/* Marker styles */
.custom-marker {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: all 0.2s;
}

.custom-marker:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.photo-marker {
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* Windows Vista style frame for map previews */
.vista-frame {
    width: 90px;
    height: 90px;
    background: url('/static/images/PFPFrame.png') no-repeat center/contain;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vista-marker {
    background: none;
    border: none;
}
.vista-photo {
    width: 60px;
    height: 60px;
    border-radius: 2px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    object-fit: cover;
}

/* Map popups */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.leaflet-popup-content {
    margin: 0;
    min-width: 200px;
}

.popup-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.9);
    background: #f6faff;
    box-shadow: 0 0 1px rgba(255,255,255,0.6) inset, 0 0 8px rgba(0,0,0,0.5);
    padding: 2px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.popup-image:hover {
    transform: scale(1.02);
}

.popup-info {
    font-size: 0.85rem;
    line-height: 1.4;
}

.popup-info strong {
    color: #2d3748;
}

/* Responsiveness */
@media (max-width: 768px) {
    .controls {
        flex-direction: column;
        gap: 1rem;
    }

    .search-section {
        min-width: auto;
    }

    .input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .input-group label {
        min-width: auto;
        margin-bottom: 0.25rem;
    }

    .button-group {
        flex-direction: column;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .modal-content {
        max-width: 98vw;
        max-height: 98vh;
    }

    #modal-image {
        max-height: 80vh;
    }
}

@media (max-width: 480px) {
    .controls {
        padding: 0.75rem;
    }

    header {
        padding: 0.75rem;
    }

    #status {
        top: 5px;
        left: 5px;
        right: 5px;
        transform: none;
    }

    .status-content {
        flex-direction: column;
        gap: 0.5rem;
    }

    #progress-bar {
        width: 100%;
    }
}

/* Loading animations */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(102, 126, 234, 0.2),
        transparent
    );
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}
