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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0f0f0f;
    color: #ffffff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    box-sizing: border-box;
}

.header {
    padding: 1rem;
    text-align: center;
    background: #0f0f0f;
    width: 100%;
    max-width: 50rem;
}

.header h1 {
    color: #ffffff;
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 300;
}

.header p {
    color: #888;
    font-size: 1rem;
    font-weight: 300;
}

.controls {
    padding: 1rem;
    text-align: center;
    background: #0f0f0f;
    width: 100%;
    max-width: 50rem;
}

.btn {
    background: #333;
    color: #ffffff;
    border: 1px solid #555;
    padding: 1rem 1rem;
    font-size: 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.direction-btn {
    width: 13rem
}

.btn:hover {
    background: #555;
    border-color: #777;
}

.btn:active {
    background: #444;
}

.btn:disabled {
    background: #222;
    border-color: #333;
    color: #666;
    cursor: not-allowed;
    opacity: 0.5;
}

.btn:disabled:hover {
    background: #222;
    border-color: #333;
    color: #666;
}

.current-site {
    background: #0f0f0f;
    padding: 1.25rem;
    width: 100%;
    max-width: 50rem;
    text-align: center;
}

.current-site h3 {
    color: #888;
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.0625rem;
}

.current-site a {
    color: #888;
    text-decoration: none;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.5;
    transition: all 0.2s ease;
    word-break: break-word;
}

.current-site a:hover {
    color: #888;
    text-decoration: none;
}

/* Style for the link box container */
.link-box {
    display: block;
    width: 100%;
    padding: 0.625rem 0.9375rem;
    border-radius: 0.375rem;
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.3);
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.link-box:hover {
    background: rgba(74, 222, 128, 0.2);
    border-color: rgba(74, 222, 128, 0.5);
    transform: translateY(-0.0625rem);
}

/* Style for when a link is actually loaded */
.current-site a[href]:not([href="#"]):not([href=""]) {
    color: #4ade80;
    text-decoration: underline;
    display: block;
}

.current-site a[href]:not([href="#"]):not([href=""]):hover {
    color: #ffffff;
}

/* Style for the description text */
.link-description {
    color: #AAA;
    text-align: center;
    word-break: break-word;
}

/* Style for the description text */
.link-tags {
    color: #888;
    text-align: center;
    word-break: break-word;
}

/* Link Stats Styles */
.link-stats {
    margin-top: 0.9375rem;
    padding-top: 0.9375rem;
    border-top: 1px solid rgba(74, 222, 128, 0.2);
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 0.9375rem;
}

.views-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 5rem;
}

.stat-icon {
    font-size: 1rem;
    margin-bottom: 0.125rem;
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: #4ade80;
    margin-bottom: 0.125rem;
}

.stat-label {
    font-size: 1rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.03125rem;
}

/* Action Buttons - now integrated into stats row */

.action-btn {
    background: #333;
    color: #ffffff;
    border: 1px solid #555;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 400;
    min-width: 6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.count-badge {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    padding: 0.125rem 0.375rem;
    border-radius: 0.625rem;
    font-size: 1rem;
    font-weight: 600;
    min-width: 1.25rem;
    text-align: center;
}

.action-btn:hover {
    background: #555;
    border-color: #777;
    transform: translateY(-0.1rem);
}

.action-btn:active {
    background: #444;
    transform: translateY(0);
}

.action-btn:disabled {
    background: #222;
    border-color: #333;
    color: #666;
    cursor: not-allowed;
    opacity: 0.5;
}

.likes-btn:hover {
    background: #059669;
    border-color: #10b981;
}

.dislikes-btn:hover {
    background: #dc2626;
    border-color: #ef4444;
}

.likes-btn.liked {
    background: #059669;
    border-color: #10b981;
    color: #ffffff;
}

.dislikes-btn.disliked {
    background: #dc2626;
    border-color: #ef4444;
    color: #ffffff;
}


/* Mobile-first responsive design */
@media (max-width: 48rem) {
    body {
        padding: 0.9375rem;
    }

    .header {
        padding: 1rem;
    }

    .controls {
        padding: 1rem;
    }

    .current-site {
        padding: 1rem;
    }

    .stats-row {
        gap: 0.5rem;
        flex-direction: column;
    }

    .action-btn {
        min-width: 100%;
        padding: 1rem 1rem;
        font-size: 1rem;
    }

    .count-badge {
        font-size: 1rem;
        padding: 0.0625rem 0.25rem;
    }

    .views-center {
        min-width: auto;
        width: 100%;
    }

    /* Ensure link box takes full width on mobile */
    .link-box {
        display: block;
        width: 100%;
        padding: 0.75rem 0.9375rem;
    }

    .current-site a {
        font-size: 1rem;
        line-height: 1.5;
    }

    .link-description {
        font-size: 1rem;
        line-height: 1.3;
    }
}

/* Add Link Button */
.add-link-btn {
    background: #059669 !important;
    border-color: #10b981 !important;
}

.add-link-btn:hover {
    background: #047857 !important;
    border-color: #059669 !important;
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0.1, 0.1, 0.1, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 0.5rem;
    width: 90%;
    max-width: 31.25rem;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-3.125rem);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border-bottom: 1px solid #333;
}

.modal-header h3 {
    color: #ffffff;
    margin: 0;
    font-size: 1rem;
}

.close {
    color: #888;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close:hover {
    color: #ffffff;
}

/* Form Styles */
#add-link-form {
    padding: 1.25rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    color: #ffffff;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #333;
    border-radius: 0.375rem;
    background: #2a2a2a;
    color: #ffffff;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #4ade80;
}

.form-group input.input-error,
.form-group textarea.input-error {
    border-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.1) !important;
    box-shadow: 0 0 0 0.125rem rgba(239, 68, 68, 0.2) !important;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #666;
}

.form-actions {
    display: flex;
    gap: 0.625rem;
    justify-content: flex-end;
    margin-top: 1.875rem;
}

.btn-secondary {
    background: #666 !important;
    border-color: #888 !important;
}

.btn-secondary:hover {
    background: #777 !important;
    border-color: #999 !important;
}

.btn-primary {
    background: #059669 !important;
    border-color: #10b981 !important;
}

.btn-primary:hover {
    background: #047857 !important;
    border-color: #059669 !important;
}

.btn-primary:disabled {
    background: #333 !important;
    border-color: #555 !important;
    color: #666 !important;
}

/* Loading state for submit button */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1rem;
    height: 1rem;
    margin: -0.5rem 0 0 -0.5rem;
    border: 0.125rem solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

/* Modal error message styles */
.modal-error {
    margin-bottom: 1.25rem;
}

.error-box {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    border-radius: 0.375rem;
    padding: 0.75rem;
}

.error-box p {
    color: #ef4444;
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
}

/* Loading Animation Styles */
.loading-animation {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    padding: 2.5rem 1.25rem;
}

.loading-spinner {
    width: 3.125rem;
    height: 3.125rem;
    border: 0.1875rem solid #333;
    border-top: 0.1875rem solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: #888;
    font-size: 1rem;
    font-weight: 300;
    margin: 0;
    text-align: center;
}

.control-buttons {
    display: flex;
    gap: 0.625rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Animation for showing buttons */
.control-buttons.show {
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(1.25rem);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive adjustments for loading animation */
@media (max-width: 48rem) {
    .loading-animation {
        padding: 1.875rem 0.9375rem;
        gap: 0.9375rem;
    }

    .loading-spinner {
        width: 2.5rem;
        height: 2.5rem;
        border-width: 0.125rem;
    }

    .loading-text {
        font-size: 1rem;
    }
}

/* API-status */
.api-status {
    position: fixed;
    top: 0.625rem;
    right: 0.625rem;
    width: 0.9375rem;
    height: 0.9375rem;
    border-radius: 50%;
    background-color: yellow;
    /* Default - API failed */
    box-shadow: 0 0 0.5rem rgba(0, 0, 0, 0.2);
    z-index: 9999;
}

.api-status.online {
    background-color: #22c55e;
    /* Green when API success */
}

.api-status.offline {
    background-color: #ef4444;
    /* Red when API failed */
}

/* Settings button and screen */
.settings-btn {
    position: fixed;
    top: 10px;
    left: 10px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1000;
}

.settings-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0f0f0f;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.settings-section {
    text-align: center;
    /* Center button and input */
    margin-top: 10px;
}

.settings-section label {
    display: block;
    margin-bottom: 6px;
    text-align: left;
}

.settings-section input {
    display: block;
    width: 90%;
    max-width: 400px;
    margin: 0 auto 10px auto;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 1rem;
}

.settings-section button {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
}

.success-message {
    margin: 16px 0;
    animation: fadeIn 0.3s ease;
}

.link-box.success-box {
    background: #0f0f0f;
    border: 2px solid #10b981;
    padding: 16px 20px;
    border-radius: 8px;
    margin-top: 8px;
}

.success-text {
    color: #00ff00;
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.5;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.error-message {
    padding: 1rem;
    text-align: center;
}