:root {
    --primary-color: #4285f4;
    --secondary-color: #34a853;
    --accent-color: #ea4335;
    --dark-color: #003366;
    --light-color: #f8f9fa;
    --text-color: #333;
    --text-light: #666;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f7fa;
    color: var(--text-color);
    line-height: 1.6;
}

nav {
    background-color: var(--dark-color);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.nav-links {
    display: flex;
    flex: 1;
    justify-content: flex-end;
}

.nav-links #loginLink,
.nav-links #logoutLink {
    margin-left: auto;
}

nav a {
    display: flex;
    align-items: center;
    color: white;
    text-align: center;
    padding: 18px 20px;
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
}

nav a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

nav a.active {
    background-color: var(--primary-color);
    font-weight: 500;
}

nav a.active:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 3px;
    background-color: white;
}

nav a i {
    margin-right: 8px;
    font-size: 0.9em;
}

/* Mobile menu toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 10px;
}

.header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
    max-width: 700px;
    margin: 0 auto;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.link-list {
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    margin-bottom: 40px;
}

.link-list-header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.link-list-header h2 {
    font-size: 1.3rem;
    font-weight: 500;
}

.link-count {
    background-color: rgba(255, 255, 255, 0.2);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.link-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}

.link-item:last-child {
    border-bottom: none;
}

.link-item:hover {
    background-color: #f9f9f9;
}

.link-info {
    display: flex;
    align-items: center;
    flex-grow: 1;
    min-width: 0; /* เพิ่มเพื่อให้ text-overflow ทำงาน */
}

.link-icon {
    margin-right: 15px;
    color: var(--primary-color);
    font-size: 1.5rem;
    width: 40px;
    text-align: center;
    flex-shrink: 0;
}

.link-details {
    flex-grow: 1;
    min-width: 0; /* สำคัญสำหรับการตัดข้อความยาว */
    overflow: hidden;
}

.link-name {
    font-weight: 500;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.link-url {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 5px;
    word-break: break-all;
    overflow-wrap: break-word;
    white-space: normal;
}

.link-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.action-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.edit-btn {
    background-color: var(--secondary-color);
    color: white;
}

.delete-btn {
    background-color: var(--accent-color);
    color: white;
}

.open-btn {
    background-color: var(--primary-color);
    color: white;
}

.action-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.add-link-form {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    margin-bottom: 40px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.submit-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.submit-btn:hover {
    background-color: #3367d6;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.empty-state i {
    font-size: 3rem;
    color: #ddd;
    margin-bottom: 20px;
}

/* Alert Box Styles */
.alert-box {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 5px;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    animation: slide-in 0.3s ease-out;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.alert-box.success {
    background-color: var(--secondary-color);
}

.alert-box.error {
    background-color: var(--accent-color);
}

.alert-box.fade-out {
    opacity: 0;
}

@keyframes slide-in {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

/* Password Prompt Styles */
.password-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
}

.prompt-content {
    background-color: white;
    padding: 25px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: fade-in 0.3s ease;
}

.prompt-content h3 {
    margin-bottom: 20px;
    color: var(--text-color);
}

.password-input {
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.prompt-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.prompt-buttons button {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.confirm-btn {
    background-color: var(--primary-color);
    color: white;
}

.cancel-btn {
    background-color: #f0f0f0;
    color: var(--text-color);
}

.prompt-buttons button:hover {
    opacity: 0.9;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Edit Dialog Styles */
.edit-dialog {
    max-width: 450px;
}

.edit-options {
    display: flex;
    margin-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.edit-option-btn {
    flex: 1;
    padding: 8px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.edit-option-btn.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    font-weight: 500;
}

.edit-option-btn:hover {
    color: var(--primary-color);
}

.form-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
    
    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        justify-content: flex-start;
    }

    .nav-links #loginLink,
    .nav-links #logoutLink {
        margin-left: 0;
    }
    
    .nav-links.active {
        display: flex;
    }
    
    nav a {
        padding: 12px;
        justify-content: center;
    }
    
    .nav-container {
        flex-direction: column;
        padding: 0px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .link-item {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
    }

    .link-info {
        width: 100%;
    }

    .link-name, .link-url {
        max-width: 100%;
        white-space: normal;
    }

    .link-actions {
        margin-top: 10px;
        align-self: flex-end;
        width: 100%;
        justify-content: flex-end;
    }

    .add-link-form {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 30px 15px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .header p {
        font-size: 1rem;
    }
    
    .action-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}