*, *::before, *::after {
    box-sizing: border-box;
}

:focus, :active {
    outline: none !important;
    /* box-shadow: none !important; */ /* This line was causing the shadow to disappear */
    -webkit-tap-highlight-color: transparent !important; /* To remove tap highlight on mobile */
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    height: 100vh;
    visibility: hidden;
}

body.ready {
    visibility: visible;
}

/* Authentication styles */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
}

.auth-box {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.auth-box h1 {
    text-align: center;
    margin: 0 0 30px;
    color: #2f3542;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    font-size: 16px;
    color: #666;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.auth-tab.active {
    color: #2f3542;
    border-bottom-color: #2f3542;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    position: relative;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #eee;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #2f3542;
}

.form-error {
    color: #ff4757;
    font-size: 14px;
    margin-top: 5px;
    min-height: 20px;
}

.auth-form button {
    background-color: #2f3542;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-form button:hover {
    background-color: #3f4658;
}

/* Existing styles */
.container {
    height: 100vh;
    overflow: hidden;
}

.filter-tabs {
    background-color: white;
    padding: 15px 20px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    position: fixed;
    bottom: 48px;
    left: 0;
    right: 0;
    z-index: 1000;
    justify-content: center;
    align-items: center;
    border-top: 1px solid #eee;
}

#profiles-container {
    padding-top: 20px;
    padding-bottom: 96px; /* filter tabs + progress bar */
    height: 100vh;
    overflow-y: auto;
    box-sizing: border-box;
}

.filter-label {
    color: #666;
    font-weight: 600;
    font-size: 14px;
    margin-right: 5px;
}

@keyframes highlightFilter {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.highlight-filter {
    animation: highlightFilter 0.5s ease-in-out;
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 20px;
    font-size: 14px;
    color: #666;
    border-radius: 20px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    background-color: #f1f1f1;
}

.tab-btn.active {
    background-color: #2f3542;
    color: white;
    border: 3px solid #1F242C; /* Darken the border color */
}

.count {
    font-size: 12px;
    margin-left: 4px;
}

#profiles-container {
    overflow-y: auto;
    padding: 20px;
    scrollbar-gutter: stable both-edges;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

#app {
    width: 600px;
    max-width: 100%;
    padding: 0 16px;
    margin: 0 auto;
    box-sizing: border-box;
}

.profile {
    width: 100%;
    margin-bottom: 20px;
    background-color: white;
    padding: 30px;
    box-sizing: border-box;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    font-size: 18px;
    line-height: 1.5;
    transition: transform 0.2s ease;
}

.profile-image-wrapper {
    width: 200px;
    height: 200px;
    margin: 0 auto 20px;
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: grab;
}

.profile-image-wrapper:active {
    cursor: grabbing;
}

.profile-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transform-origin: 0 0;
    border-radius: 10px;
}

[tabindex="0"]:focus {
    outline: none;
}

@media screen and (min-width: 601px) {
    .profile-image-wrapper {
        width: 100%;
        height: auto;
        max-height: 600px;
        margin: 0 auto 30px;
        aspect-ratio: 1;
    }

    .profile-image {
        width: 100%;
        height: 100%;
        max-height: 600px;
    }

    .profile {
        padding: 40px;
        margin-bottom: 30px;
    }

    #app {
        width: 800px;
    }
}

.profile-content {
    margin-bottom: 20px;
}

.profile:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.profile-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
    padding: 5px;
    overflow: visible;
}

button {
    padding: 12px 24px;
    font-size: 16px;
    border: 3px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
    border-radius: 25px;
    font-weight: 600;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.2s ease;
}

button:focus,
button:active {
    outline: none;
    box-shadow: none;
}

button:hover:not(.button-active):not(.button-transition) {
    transform: scale(1.033);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.nope {
    background-color: #ff4757;
    color: white;
}
.nope.button-active {
    border-color: #cc3a42; /* Darker red */
}

.maybe {
    background-color: #ffa502;
    color: white;
}
.maybe.button-active {
    border-color: #cc8400; /* Darker orange */
}

.yep {
    background-color: #2ed573;
    color: white;
}
.yep.button-active {
    border-color: #24AA5C; /* Darker green */
}

.button-active {
    transform: scale(1.1);
    border: 8px solid; /* General thicker border, color will be overridden by specific classes */
}

.profile-comments {
    margin-top: 20px;
}

.comments-wrapper {
    position: relative;
    width: 100%;
    margin-top: 10px;
}

.comments-textarea {
    width: 100%;
    padding: 20px 15px 25px;
    border: 2px solid #eee;
    border-radius: 10px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s ease, height 0.1s ease;
    box-sizing: border-box;
    overflow: hidden;
    min-height: 45px;
    height: auto;
}

.comments-textarea:focus {
    outline: none;
    border-color: #2ed573;
}

.comments-textarea::placeholder {
    color: #666;
    opacity: 1;
}

.comments-textarea:focus::placeholder {
    opacity: 0;
}

.comments-label {
    position: absolute;
    top: -4px;
    left: 11px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
    pointer-events: none;
    background: white;
    padding: 0 6px;
    color: #666;
    display: none;
}

.comments-textarea[data-has-content="true"] ~ .comments-label {
    display: block;
}

.comments-textarea:focus ~ .comments-label {
    color: black;
}

.save-status {
    position: absolute;
    bottom: 4px;
    right: 15px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
    pointer-events: none;
    background: white;
    padding: 0 6px;
}

.fixed-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: white;
    padding: 8px 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    border-top: 1px solid #eee;
    touch-action: none;
    pointer-events: none;
}

.fixed-bottom * {
    pointer-events: auto;
}

.progress-section {
    width: 600px;
    max-width: 100%;
    padding: 0 16px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 15px;
    box-sizing: border-box;
}

.progress-text {
    font-size: 14px;
    color: #666;
    font-weight: 500;
    white-space: nowrap;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background-color: #f1f1f1;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: #2ed573;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.undo-button {
    background-color: #2f3542;
    color: white;
    width: 85px;
    height: 32px;
    padding: 0;
    font-size: 14px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.undo-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.undo-button:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.logout-button {
    background: none;
    border: 2px solid #2f3542;
    color: #2f3542;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 10px;
}

.logout-button:hover {
    background-color: #2f3542;
    color: white;
}

.unsaved {
    color: #ff4757;
}

.saved {
    color: #2ed573;
}

@keyframes highlightProfile {
    0% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); }
    50% { box-shadow: 0 4px 20px rgba(47, 53, 66, 0.25); }
    100% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); }
}

.highlight-profile {
    animation: highlightProfile 2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes buttonTransition {
    0% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.button-transition {
    animation: buttonTransition 0.5s ease-out forwards;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    cursor: zoom-out;
}

.modal-content {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

.modal-image-wrapper {
    position: relative;
    cursor: grab;
    width: 100%;
    height: 100%;
}

.modal-image-wrapper:active {
    cursor: grabbing;
}

.modal-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    margin: 0;
    transform-origin: center;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.5);
    border: 3px solid white;
    border-radius: 8px;
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    z-index: 1001;
}

.modal-close:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

@media screen and (max-width: 600px) {
    .modal-close {
        top: 5vh;
        right: 5vw;
    }

    .modal-content {
        width: 100%;
        height: 100%;
    }
    .filter-tabs {
        padding: 4px 6px;
        gap: 1px;
    }

    .tab-btn {
        padding: 4px 6px;
        font-size: 12px;
    }

    .filter-label {
        font-size: 12px;
        margin-right: 1px;
    }

    .count {
        margin-left: 1px;
    }
    
    .modal-loading-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.7);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        color: white;
        font-size: 1.2em;
        z-index: 10; /* Above the image, below the close button */
    }
    
    .spinner {
        border: 4px solid rgba(255, 255, 255, 0.3);
        border-top: 4px solid #fff;
        border-radius: 50%;
        width: 30px;
        height: 30px;
        animation: spin 1s linear infinite;
        margin-top: 10px;
    }
    
    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }

    .profile-controls button {
        padding: 8px 16px;
        font-size: 14px;
    }

    .profile-controls {
        gap: 10px;
        margin: 15px 0;
    }

    .button-active {
        transform: scale(1.05);
    }

    .auth-box {
        padding: 20px;
    }

    .profile {
        padding-top: 20px; /* Add padding to the top of each profile for mobile */
    }
}

/* Pull to Refresh Indicator */
.pull-to-refresh-indicator {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px; /* Or adjust as needed */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f1f1f1;
    color: #666;
    font-size: 16px;
    font-weight: bold;
    transform: translateY(-100%); /* Initially hidden above the container */
    opacity: 0;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
    z-index: 999; /* Below app container */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loading-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px; /* Ensure it's visible */
    font-size: 1.2em;
    color: #666;
    background-color: #f4f4f4;
    padding: 20px;
    border-radius: 8px;
    margin-top: 50px;
}



/* Dark Mode Styles */
body.dark-mode {
    background-color: #1a1a1a; /* Dark background */
    color: #e0e0e0; /* Light text color */
}

body.dark-mode .auth-box,
body.dark-mode .filter-tabs,
body.dark-mode .profile,
body.dark-mode .fixed-bottom,
body.dark-mode .comments-label,
body.dark-mode .save-status {
    background-color: #2a2a2a; /* Darker background for elements */
    color: #e0e0e0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); /* Darker shadow */
}

body.dark-mode .auth-box h1,
body.dark-mode .auth-tab.active {
    color: #f0f0f0;
}

body.dark-mode .auth-tab {
    color: #b0b0b0;
    border-bottom-color: transparent;
}

body.dark-mode .auth-tab.active {
    border-bottom-color: #f0f0f0;
}

body.dark-mode .auth-form input {
    border-color: #444;
    background-color: #333;
    color: #e0e0e0;
}

body.dark-mode .auth-form input:focus {
    border-color: #555;
}

body.dark-mode .auth-form button {
    background-color: #444;
    color: white;
}

body.dark-mode .auth-form button:hover {
    background-color: #555;
}

body.dark-mode .tab-btn {
    color: #b0b0b0;
}

body.dark-mode .tab-btn:hover {
    background-color: #333;
}

body.dark-mode .tab-btn.active {
    background-color: #f0f0f0;
    color: #2a2a2a;
    border-color: #c0c0c0;
}

body.dark-mode .filter-label,
body.dark-mode .progress-text,
body.dark-mode .pull-to-refresh-indicator,
body.dark-mode .loading-indicator {
    color: #b0b0b0;
}

body.dark-mode .progress-bar {
    background-color: #333;
}

body.dark-mode .undo-button {
    background-color: #444;
    color: #e0e0e0;
}

body.dark-mode .undo-button:not(:disabled):hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

body.dark-mode .logout-button {
    border-color: #b0b0b0;
    color: #b0b0b0;
}

body.dark-mode .logout-button:hover {
    background-color: #b0b0b0;
    color: #2a2a2a;
}

body.dark-mode .comments-textarea {
    background-color: #333;
    border-color: #444;
    color: #e0e0e0;
}

body.dark-mode .comments-textarea:focus {
    border-color: #2ed573; /* Keep original green for focus */
}

body.dark-mode .comments-textarea::placeholder {
    color: #b0b0b0;
}

body.dark-mode .comments-textarea:focus ~ .comments-label {
    color: #f0f0f0;
}

body.dark-mode .modal {
    background-color: rgba(0, 0, 0, 0.95);
}

body.dark-mode .modal-close {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    color: #e0e0e0;
}

body.dark-mode .modal-close:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

body.dark-mode .dark-mode-toggle {
    background-color: #444;
    color: white;
    border: 3px solid #666;
}

body.dark-mode .dark-mode-toggle:hover {
    background-color: #555;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

@media screen and (max-width: 600px) {
    body.dark-mode .filter-tabs {
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.3);
    }
}
