:root {
    --bg-color: #f0f2f5; /* Lighter background */
    --card-bg: #ffffff; /* Pure white cards */
    --text-color: #212529; /* Darker text for higher contrast */
    --primary-color: #6f42c1; /* Deep purple */
    --primary-hover: #5a35a1; /* Darker purple on hover */
    --secondary-color: #fd7e14; /* Vibrant orange */
    --accent-color: #20c997; /* Teal/mint green */
    --border-color: #e9ecef; /* Light border */
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.1); /* Slightly stronger, softer shadow */
    --input-bg: #f1f3f5; /* Light input background */
    --input-border: #ced4da; /* Medium gray input border */
    --tag-bg: #e0cffc; /* Light purple tag */
    --tag-text: #6f42c1; /* Deep purple tag text */
    --deleted-bg: #ffe0e6; /* Light pinkish-red for deleted */
    --deleted-text: #dc3545; /* Strong red for deleted text */
    --font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Modern font */
    --highlight-bg: #fff3b0; /* Soft yellow highlight */
    --highlight-text: #8a6d00; /* Dark yellow highlight text */
    --link-color: #007bff; /* Standard blue link */
    --link-hover: #0056b3; /* Darker blue on hover */
}

.dark-mode {
    --bg-color: #1a1d20; /* Darker background */
    --card-bg: #212529; /* Darker card background */
    --text-color: #f8f9fa; /* Lighter text for higher contrast */
    --primary-color: #9c73e6; /* Lighter purple for dark mode */
    --primary-hover: #8a62d0; /* Darker purple on hover */
    --secondary-color: #ff9f40; /* Lighter orange */
    --accent-color: #4dd6b7; /* Lighter teal/mint */
    --border-color: #495057; /* Darker border */
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.4); /* More pronounced shadow */
    --input-bg: #343a40; /* Dark input background */
    --input-border: #6c757d; /* Medium dark gray input border */
    --tag-bg: #4a306d; /* Dark purple tag */
    --tag-text: #d0b8f0; /* Light purple tag text */
    --deleted-bg: #6d3545; /* Darker pinkish-red for deleted */
    --deleted-text: #ffb3c0; /* Lighter red for deleted text */
    --highlight-bg: #5a5a00; /* Dark yellow highlight */
    --highlight-text: #ffff99; /* Light yellow highlight text */
    --link-color: #66b3ff; /* Lighter blue link for dark mode */
    --link-hover: #3399ff; /* Darker blue on hover */
}

/* Link differentiation */
.field-value a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.field-value a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6; /* Increased line height for readability */
    transition: background-color 0.3s ease, color 0.3s ease;
    padding: 20px;
    font-size: 16px; /* Increased base font size */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 25px;
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: background-color 0.3s ease;
    border: 1px solid var(--border-color);
}

/* Header Styles */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    gap: 16px;
}

header h1 {
    font-size: 1.8em; /* Increased header font size */
    color: var(--primary-color);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

header h1 i {
    margin-right: 8px;
}

.search-container {
    flex-grow: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.header-controls {
    display: flex;
    gap: 8px;
    position: relative;
    z-index: 100;
}

.quick-add-btn, .menu-btn {
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px; /* Increased button font size */
}

.quick-add-btn:hover, .menu-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Menu Dropdown */
.menu-dropdown {
    position: fixed;
    top: 60px;
    right: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 1000;
    min-width: 200px;
    display: none;
    padding: 8px 0;
    max-height: 300px;
    overflow-y: auto;
}

.menu-dropdown.show {
    display: block;
}

.menu-dropdown button {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-color);
    padding: 12px 16px;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 16px; /* Increased menu button font size */
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-dropdown button:hover {
    background: var(--bg-color);
}

.fuzzy-toggle {
    justify-content: space-between !important;
}



.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-color);
    opacity: 0.6;
    z-index: 1;
}

#searchInput {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 16px; /* Increased search input font size */
    transition: border-color 0.2s ease;
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary-color);
}

.clear-search {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-color);
    opacity: 0.6;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: none;
}

.clear-search:hover {
    opacity: 1;
    background: var(--bg-color);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--card-bg);
    margin: 10% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    color: var(--primary-color);
    font-size: 1.4em; /* Increased modal header font size */
}

.close {
    color: var(--text-color);
    font-size: 28px; /* Increased close button font size */
    font-weight: bold;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.close:hover {
    opacity: 1;
}

.modal-body {
    padding: 20px;
}

.modal-body input, .modal-body textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 16px; /* Increased modal input font size */
    resize: vertical;
}

.modal-body textarea {
    min-height: 100px;
}

.modal-body button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px; /* Increased modal button font size */
    transition: background-color 0.2s ease;
    width: 100%;
}

.modal-body button:hover {
    background: var(--primary-hover);
}

/* Add Entry Form */
.add-entry-form {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 15px;
}

.add-entry-form h3 {
    color: var(--primary-color);
    margin-bottom: 5px;
    font-size: 1.3em; /* Increased form header font size */
}

.add-entry-form input, .add-entry-form textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 0;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 16px; /* Increased form input font size */
}

.field-group {
    display: grid;
    grid-template-columns: 1fr 2fr auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    position: relative;
}

.field-group .field-name {
    margin-bottom: 0;
}

.field-group .field-value {
    min-height: 38px;
    resize: vertical;
    margin-bottom: 0;
}

.remove-field {
    position: static;
    width: 30px;
    height: 30px;
    font-size: 16px; /* Increased remove field button font size */
    border-radius: 6px;
    background: var(--secondary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.form-actions button {
    flex: 1;
    min-width: 100px;
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px; /* Increased form action button font size */
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

#addField {
    background: var(--accent-color);
    color: white;
}

#saveEntry {
    background: var(--primary-color);
    color: white;
}

#cancelEntry {
    background: var(--border-color);
    color: var(--text-color);
}

.form-actions button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Entries Container */
.entries-container {
    display: grid;
    gap: 15px;
}

.entry {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    /* padding: 20px; */
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
    position: relative;
}

.entry:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.entry.deleted {
    background: var(--deleted-bg);
    color: var(--deleted-text);
    opacity: 0.7;
}

.entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* margin-bottom: 15px; */
    /* padding-bottom: 10px; */
    /* border-bottom: 1px solid var(--border-color); */
    padding: 12px 20px;
}

.entry-header.clickable {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.entry-header.clickable:hover {
    background-color: var(--bg-color);
    border-radius: 8px;
    /* margin: -5px; */
    /* padding: 15px 5px; */
}

.title-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.expand-icon {
    color: var(--primary-color);
    font-size: 1em; /* Increased expand icon font size */
    transition: transform 0.3s ease;
    cursor: pointer;
}

.expand-icon.expanded {
    transform: rotate(90deg);
}

.entry-title {
    font-size: 1.3em; /* Increased entry title font size */
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

.entry-actions {
    display: flex;
    gap: 8px;
}

.entry-actions button {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px; /* Increased action button font size */
    transition: all 0.2s ease;
}

.entry-actions button:hover {
    background: var(--bg-color);
}

.entry-actions .delete-btn:hover {
    background: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
}

.entry-fields {
    display: grid;
    gap: 12px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.entry-fields.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    gap: 0;
}

.entry-fields.expanded {
    max-height: 2000px;
    opacity: 1;
    /* margin-top: 15px; */
    padding: 0 20px 20px;
}

.field {
    /* background: var(--bg-color); */
    padding: 12px 0;
    border-radius: 8px;
    /* border-left: 3px solid var(--primary-color); */
    border-bottom: 1px solid var(--border-color);
}

.field:last-child {
    border-bottom: none;
}

.field-name {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 4px;
    font-size: 1em; /* Increased field name font size */
}



.field-value {
    color: var(--text-color);
    word-wrap: break-word;
    white-space: pre-wrap;
    font-size: 1em;
    line-height: 1.5;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.field-value-text {
    flex: 1;
}

.copy-btn {
    background: none;
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    padding: 0 0 0 8px;
    cursor: pointer;
    font-size: 0.9em;
    opacity: 0.6;
    transition: all 0.2s ease;
    display: inline-block;
    vertical-align: middle;
}

.copy-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.copy-btn:active {
    transform: scale(0.95);
}

/* Highlight for search results */
.highlight {
    background-color: var(--highlight-bg);
    color: var(--highlight-text);
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-color);
    opacity: 0.6;
}

.no-results i {
    font-size: 3.5em; /* Increased no results icon size */
    margin-bottom: 15px;
    opacity: 0.3;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px; /* Adjusted padding for mobile */
    }
    
    .container {
        padding: 15px; /* Adjusted padding for mobile */
        border-radius: 10px; /* Adjusted border-radius for mobile */
    }
    
    header h1 {
        font-size: 1.5em; /* Adjusted header font size for mobile */
    }
    
    .modal-content {
        margin: 5% auto;
        width: 95%;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions button {
        min-width: auto;
    }
    
    .field-group {
        padding: 12px;
    }
    
    .entry {
        padding: 15px;
    }
    
    .menu-dropdown {
        min-width: 180px;
    }
}

/* iPhone 14 Pro specific optimizations */
@media (max-width: 430px) {
    body {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .container {
        padding: 10px; /* Adjusted padding for mobile */
    }
    
    header {
        margin-bottom: 15px;
    }
    
    .quick-add-btn, .menu-btn {
        padding: 10px 12px; /* Adjusted padding for mobile */
        font-size: 16px; /* Adjusted font size for mobile */
    }
    
    #searchInput {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px 12px 12px 40px; /* Adjusted padding for mobile */
    }
    
    .modal-body input, .modal-body textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .add-entry-form input, .add-entry-form textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Animation for entries */
.entry {
    animation: fadeInUp 0.3s ease;
}

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

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Smooth transitions */
* {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}