/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus indicators */
button:focus,
input:focus,
.password-toggle:focus {
    outline: 2px solid #4ecdc4;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .name {
        background: linear-gradient(45deg, #ffffff, #000000, #ffffff);
    }
    
    .link-button {
        border: 2px solid #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .name {
        animation: none;
    }
    
    .link-button {
        transition: none;
    }
}

/* Prevent layout shift during loading */
.links-section:empty::before {
    content: '';
    display: block;
    height: 200px;
    width: 100%;
}

/* Loading state for buttons */
.link-button {
    /* Prevent layout shift */
    min-height: 60px;
    contain: layout;
}

/* Font display optimization */

/* Reset và base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px; /* Explicit font size to avoid deprecated API */
    -webkit-text-size-adjust: 100%; /* Prevent font size adjustment */
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 1rem; /* Use rem instead of px for better scaling */
    background: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), url('bg.webp');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    color: white;
    line-height: 1.6;
    /* Prevent font size issues */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Font Awesome font display optimization */
.fab, .fas, .far, .fal, .fad {
    font-family: "Font Awesome 6 Brands", "Font Awesome 6 Free", "FontAwesome", sans-serif;
    font-weight: 900;
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-display: swap;
}

.fab {
    font-family: "Font Awesome 6 Brands", "FontAwesome", sans-serif;
    font-weight: 400;
    font-display: swap;
}

/* Prevent deprecated API warnings */
* {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Ensure all elements have explicit font-size */
h1, h2, h3, h4, h5, h6 {
    font-size: inherit;
}

/* Prevent user agent font size issues */
input, button, select, textarea {
    font-size: inherit;
    font-family: inherit;
}

.container {
    width: 100%;
    margin: 0 auto;
    padding: 25px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* Prevent layout shift */
    contain: layout style;
    /* Reserve space for content */
    min-height: 100vh;
}

/* Profile Section */
.profile-section {
    text-align: center;
    margin-bottom: 30px;
    /* Prevent layout shift */
    contain: layout;
    min-height: 300px;
}

.profile-image {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Prevent layout shift */
    contain: layout;
    min-height: 150px;
}

.profile-image img {
    width: 150px;
    height: 150px;
    border-radius: 0;
    /* Prevent layout shift */
    display: block;
    object-fit: contain;
    margin: 0 auto;
    contain: layout;
}

.name {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 10px;
    background: linear-gradient(45deg, #ffffff, #e0e0e0, #ffffff);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease-in-out infinite;
    will-change: background-position;
    transform: translateZ(0);
}

@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

.title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    opacity: 0.95;
    letter-spacing: 0.5px;
}

.description {
    font-size: 16px;
    opacity: 0.9;
    max-width: 350px;
    margin: 0 auto;
    line-height: 1.6;
    letter-spacing: 0.3px;
}


/* Section Title */
.section-title {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #ffffff, #f0f0f0, #ffffff);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 4s ease-in-out infinite;
    letter-spacing: 1px;
}

/* Contact Section */
.contact-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
    /* Prevent layout shift */
    contain: layout;
    min-height: 200px;
}

.contact-section .section-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 25px;
    text-align: center;
}

.contact-section .links-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    min-height: 200px;
    /* Prevent layout shift */
    contain: layout;
}

.contact-section .links-section:empty::before {
    content: '';
    display: block;
    height: 200px;
    width: 100%;
}

/* ===== CONFIG PAGE STYLES ===== */

/* Config Container */
.config-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Login and Config Forms */
.login-form, .config-form {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(15px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Form Groups */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: white;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 16px;
    box-sizing: border-box;
}

.form-group input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

.btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-danger {
    background: linear-gradient(45deg, #ff6b6b, #ee5a52);
    color: white;
}

.btn-small {
    padding: 8px 15px;
    font-size: 14px;
    width: auto;
    margin: 0 5px;
}

/* Button Items */
.button-item {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    margin-bottom: 15px;
    overflow: hidden;
}

.collapsible-header {
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    transition: background 0.3s ease;
}

.collapsible-header:hover {
    background: rgba(255, 255, 255, 0.2);
}

.button-text {
    font-weight: 600;
    color: white;
}

.collapsible-arrow {
    color: white;
    transition: transform 0.3s ease;
}

.collapsible-content {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: none;
    border-radius: 0 0 10px 10px;
    padding: 0 15px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.collapsible-content.expanded {
    padding: 15px;
    max-height: 500px;
}

/* Icon Selector */
.icon-selector {
    position: relative;
}

.icon-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.current-icon {
    font-size: 20px;
    color: white;
}

.chevron {
    color: white;
    transition: transform 0.3s ease;
}

.icon-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 8px;
    padding: 10px;
    display: none;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
}

.icon-options.show {
    display: grid;
}

.icon-option {
    padding: 8px;
    text-align: center;
    cursor: pointer;
    border-radius: 5px;
    transition: background 0.3s ease;
}

.icon-option:hover {
    background: rgba(255, 255, 255, 0.2);
}

.icon-option i {
    font-size: 18px;
    color: white;
}

/* Delete Button */
.delete-button {
    width: 100%;
    padding: 10px;
    background: linear-gradient(45deg, #ff6b6b, #ee5a52);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.delete-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Password Section */
.password-section {
    margin-top: 30px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    overflow: hidden;
}

.password-header {
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
}

.password-arrow {
    color: white;
    transition: transform 0.3s ease;
}

/* Config Messages */
.config-message {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 10px;
    text-align: center;
    font-weight: 600;
    display: none;
}

.config-message.success {
    background: rgba(76, 175, 80, 0.3);
    color: #4caf50;
    border: 2px solid rgba(76, 175, 80, 0.5);
}

.config-message.error {
    background: rgba(244, 67, 54, 0.3);
    color: #f44336;
    border: 2px solid rgba(244, 67, 54, 0.5);
}

.hidden {
    display: none !important;
}

/* Config Page Headings */
.config-container h1, .config-container h2 {
    color: white;
    text-align: center;
    margin-bottom: 30px;
}

.config-container h1 {
    font-size: 28px;
    background: linear-gradient(45deg, #ffffff, #e0e0e0, #ffffff);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 4s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.section-title {
    font-size: 20px;
    margin-bottom: 20px;
    color: white;
}

.buttons-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* ===== END CONFIG PAGE STYLES ===== */

/* Additional Config Page Styles */
.config-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.login-form, .config-form {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(15px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: white;
    font-size: 16px;
}

.form-group input, .form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 16px;
    transition: all 0.3s ease;
}

.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.2);
}

.form-group input::placeholder, .form-group textarea::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(45deg, #4A90E2, #7B68EE);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-danger {
    background: linear-gradient(45deg, #ff6b6b, #ee5a52);
}

.hidden {
    display: none;
}

.error-message {
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid rgba(255, 107, 107, 0.5);
    color: #ff6b6b;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: center;
}

.success-message {
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid rgba(76, 175, 80, 0.5);
    color: #4caf50;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: center;
}

.link-item {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
}

.link-item h4 {
    margin: 0 0 10px 0;
    color: white;
    font-size: 18px;
}

.link-item p {
    margin: 5px 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    word-break: break-all;
}

.form-title {
    text-align: center;
    margin-bottom: 25px;
    font-size: 24px;
    font-weight: 700;
    color: white;
    background: linear-gradient(45deg, #ffffff, #e0e0e0, #ffffff);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease-in-out infinite;
}

.section-divider {
    margin: 25px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.section-divider h3 {
    margin: 0 0 20px 0;
    color: white;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
}

.button-item {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 0;
    margin-bottom: 15px;
}

.delete-button {
    background: linear-gradient(45deg, #ff6b6b, #ee5a52);
    border: none;
    border-radius: 8px;
    padding: 8px 15px;
    color: white;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
    width: fit-content;
}

.delete-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
    background: linear-gradient(45deg, #ff5252, #e53935);
}

.delete-button i {
    font-size: 12px;
}

.icon-selector {
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 8px;
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.icon-selector.show {
    display: grid;
}

.icon-trigger {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.icon-trigger:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.icon-trigger .current-icon {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-trigger .current-icon i {
    font-size: 20px;
    color: white;
}

.icon-trigger .current-icon span {
    color: white;
    font-size: 14px;
}

.icon-trigger .chevron {
    color: white;
    font-size: 14px;
    transition: transform 0.3s ease;
}

.icon-trigger .chevron.expanded {
    transform: rotate(180deg);
}

.icon-option {
    width: 50px;
    height: 50px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
}

.icon-option:hover, .icon-option.selected {
    border-color: #4A90E2;
    background: rgba(74, 144, 226, 0.2);
    transform: scale(1.05);
}

.icon-option i {
    font-size: 20px;
    color: white;
}

.collapsible-section {
    margin-bottom: 15px;
}

.collapsible-header {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    margin-bottom: 0;
}

.collapsible-header:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.collapsible-header h4 {
    margin: 0;
    color: white;
    font-size: 16px;
    font-weight: 600;
}

.collapsible-arrow {
    color: white;
    font-size: 18px;
    transition: transform 0.3s ease;
}

.collapsible-arrow.expanded {
    transform: rotate(180deg);
}

.collapsible-content .form-group {
    margin-bottom: 15px;
}

/* Password section styling is above */

.password-toggle {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    margin-bottom: 0;
}

.password-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.password-toggle h3 {
    margin: 0;
    color: white;
    font-size: 18px;
    font-weight: 600;
}

.password-content {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-top: none;
    border-radius: 0 0 10px 10px;
    padding: 0 15px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.password-content.expanded {
    padding: 15px;
    max-height: 400px;
}

.link-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(15px);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 30px;
    padding: 25px 35px;
    text-decoration: none;
    color: white;
    font-weight: 700;
    font-size: 24px;
    transition: all 0.3s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    letter-spacing: 1px;
    min-height: 90px;
    width: 100%;
    margin: 0 auto;
}

.link-button i {
    font-size: 32px;
    width: 40px;
    text-align: center;
}

.link-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.6);
}

.link-button:active {
    transform: translateY(0);
}

/* Responsive design for different screen sizes */
@media (min-width: 768px) {
    .link-button {
        width: 100%;
        max-width: 500px;
    }
}

@media (min-width: 1024px) {
    .link-button {
        width: 100%;
        max-width: 600px;
    }
}

/* Profile image responsive */
@media (max-width: 480px) {
    .profile-image img {
        width: 120px;
        height: 120px;
    }
}

@media (min-width: 768px) {
    .profile-image img {
        width: 180px;
        height: 180px;
    }
}

/* Responsive Design */
@media (max-width: 480px) {
    .container {
        padding: 20px;
        width: 100%;
    }
    
    .link-button {
        width: 100%;
        padding: 20px 30px;
        font-size: 22px;
    }
    
    .profile-image img {
        width: 130px;
        height: 130px;
    }
    
    .name {
        font-size: 28px;
    }
    
    .title {
        font-size: 16px;
    }
    
    .description {
        font-size: 15px;
        max-width: 300px;
    }
    
    .section-title {
        font-size: 24px;
    }
    
    .link-button {
        padding: 20px 25px;
        font-size: 18px;
        gap: 15px;
        min-height: 60px;
    }
    
    .link-button i {
        font-size: 24px;
        width: 28px;
    }
}

@media (max-width: 360px) {
    .container {
        padding: 15px;
    }
    
    .profile-image img {
        width: 120px;
        height: 120px;
    }
    
    .name {
        font-size: 26px;
    }
    
    .title {
        font-size: 15px;
    }
    
    .description {
        font-size: 14px;
        max-width: 280px;
    }
    
    .section-title {
        font-size: 22px;
    }
    
    .link-button {
        padding: 18px 22px;
        font-size: 17px;
        gap: 12px;
        min-height: 55px;
    }
    
    .link-button i {
        font-size: 22px;
        width: 26px;
    }
}

/* Smooth animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.profile-section,
.section-title,
.links-section {
    animation: fadeInUp 0.6s ease-out;
}

.section-title {
    animation-delay: 0.2s;
}

.links-section {
    animation-delay: 0.4s;
}