/* *************
   CSS variables
   ************* */

:root {
    --primary-color: #8b5cf6;
    --primary-hover: #7c3aed;
    --secondary-color: #6c757d;
    --secondary-hover: #545b62;
    --success-color: #22c55e;
    --success-hover: #16a34a;
    --danger-color: #dc3545;
    --danger-hover: #c82333;
    --background: #f8f9fa;
    --surface: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border: #dee2e6;
    --border-light: #eee;
}

[data-theme="dark"] {
    --primary-color: #8b5cf6;
    --primary-hover: #7c3aed;
    --secondary-color: #6b7280;
    --secondary-hover: #4b5563;
    --background: #1a1a1a;
    --surface: #2a2a2a;
    --text-primary: #f5f5f5;
    --text-secondary: #a3a3a3;
    --border: #404040;
    --border-light: #525252;
}

/* **********
   Base setup
   ********** */

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

/* * {
    transition: color 0.3s ease background-color 0.3s ease, border-color 0.3s ease, border-bottom-color 0.3s ease
} */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* *****************
   Layout components
   ***************** */

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

.main-layout {
    display: flex;
    gap: 20px;
}

.content {
    flex: 1;
}

.sidebar {
    width: 25%;
    flex-shrink: 0;
}

.header {
    padding: 10px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.header h1 {
    color: var(--primary-color);
    margin: 0;
}

.header h1 a {
    color: inherit;
    text-decoration: none;
}

.header h1 a:hover {
    color: inherit;
}

.section-header {
    line-height: 1;
    margin-bottom: 6px;
    margin-top: 0;
}

.section-area {
    line-height: 1.6;
}


/* *********************
   Navigation & controls
   ********************* */

.controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
}

.search-box {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    background-color: var(--surface);
    color: var(--text-primary);
    width: 25%;
}

.search-box:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* *******
   Buttons
   ******* */

.btn {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: 1px solid var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-secondary {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--border);
}

.btn-secondary:disabled {
    background-color: var(--border);
    opacity: 0.75;
    cursor: not-allowed;
}

.btn-success {
    background-color: var(--success-color);
    border: 1px solid var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: var(--success-hover);
    border-color: var(--success-hover);
}

.btn-danger {
    background-color: var(--danger-color);
    border: 1px solid var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
    border-color: var(--danger-hover);
}

/* Button text utilities */
.btn-primary .mobile-text {
    display: none;
}

.btn-primary .desktop-text {
    display: inline;
}

/* Button sizing variations */
.link-tags .btn {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
    line-height: 1;
}

/* **************
   Forms & modals
   ************** */

/* Tag selection in modal */
.tag-selection {
    margin-bottom: 10px;
}

.available-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.available-tags .tag {
    margin-right: 0;
    margin-bottom: 0;
}

.available-tags .tag.selected {
    background: var(--primary-color);
    color: white;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal-content {
    background: var(--background);
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    margin: 50px auto;
    padding: 15px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
}

.close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    padding: 0;
}

.close:hover {
    color: var(--text-primary);
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    background-color: var(--surface);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox input {
    width: auto;
}

.checkbox label {
    margin-bottom: 0;
    margin-top: 0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.button-group {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ******************
   Content components
   ****************** */

/* Sidebar tags */
.tag {
    background: var(--border);
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-primary);
    display: inline-block;
    margin-right: 6px;
    margin-bottom: 6px;
}

.tag:hover {
    background: var(--border-light);
}

.tag.active {
    background: var(--primary-color);
    color: white;
}

/* Links */
.links {
    background: var(--background);
}

.link {
    padding: 6px 0;
    display: flex;
    gap: 8px;
}

.link:first-child {
    padding-top: 0;
}

.link-unread-dot {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 2px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.unread-dot {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 12px;
}

.link-content {
    flex: 1;
}

.link-title {
    font-weight: normal;
    margin-bottom: 2px;
    font-size: 14px;
}

.link-title a {
    color: var(--text-primary);
    text-decoration: none;
}

.link-title a:hover {
    text-decoration: underline;
}

.link-favicon-inline {
    width: 16px;
    height: 16px;
    vertical-align: sub;
    margin-right: 2px;
}

.link-url {
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 2px;
}

.link-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.link-tags {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    align-items: center;
}

.link-tag {
    background: var(--border);
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    height: auto;
    line-height: 1;
}

.link-tag:hover {
    background: var(--border-light);
    border-color: var(--border-light);
}

.link-tag.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}



/* Bookmarklet */
.bookmarklet-section {
    margin-top: 15px;
    padding: 8px 10px;
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.bookmarklet-section p {
    font-size: 12px;
    color: var(--text-secondary);
}

.bookmarklet-section .btn {
    font-size: 13px;
    margin: 5px 0;
    padding: 8px 12px;
}

/* ***************
   Utility classes
   *************** */

/* Emoji utilities */
.emoji {
    filter: grayscale(1);
    display: inline-block;
}

.emoji-sm {
    transform: scale(0.8);
}

.emoji-sm-flip {
    transform: scale(0.8) scaleX(-1);
}

.emoji-flip {
    transform: scaleX(-1);
}

:root .emoji-two-tone {
    filter: grayscale(1) contrast(3) invert(1) !important;
}

[data-theme="dark"] .emoji-two-tone {
    filter: grayscale(1) contrast(3) !important;
}

/* Light mode - make emojis dark */
:root .emoji {
    filter: grayscale(1) brightness(0);
}

/* Dark mode - make emojis light */
[data-theme="dark"] .emoji {
    filter: grayscale(1) brightness(0) invert(1);
}

/* Primary, success, and danger button emojis should always be light */
.btn-primary .emoji,
.btn-success .emoji,
.btn-danger .emoji {
    filter: grayscale(1) brightness(0) invert(1) !important;
}

/* RSS icon SVG */
.rss-icon {
    display: inline-block;
    width: 12px;
    height: 12px;
    vertical-align: -2px;
}

/* Dropdown chevron */
.dropdown-chevron {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 3px;
    margin-right: -4px;
    opacity: 0.6;
    vertical-align: -3px;
}

/* RSS icon */
.rss-icon-lg {
    width: 16px;
    height: 16px;
    margin-left: 4px;
    margin-right: 3px;
}

.rss-icon svg {
    width: 100%;
    height: 100%;
}

/* State utilities */
.loading {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 12px;
}

/* Loading spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 140px;
    z-index: 2000;
    pointer-events: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 6px solid var(--border);
    border-top: 6px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 0.35s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

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

.empty-state h3 {
    margin-bottom: 10px;
}

.hidden {
    display: none;
}

.code {
    font-family: monospace;
}

/* *******************
   Responsive / mobile
   ******************* */

@media (max-width: 768px) {

    /* Layout adjustments */
    .main-layout {
        flex-direction: column;
        gap: 0;
    }

    .sidebar {
        width: 100%;
        order: -1;
        padding-top: 0;
        margin-bottom: 8px;
        border-bottom: 1px solid var(--border);
        padding-bottom: 10px;
    }

    .container {
        padding: 5px 15px 20px 15px;
    }

    /* Navigation & Controls */
    .controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .controls-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }

    .controls-buttons .btn {
        flex: none;
        min-width: max-content;
        white-space: nowrap;
        font-size: 13px;
    }

    .controls-buttons #statusBtn {
        min-width: 91px;
    }

    .controls-buttons #sortBtn {
        min-width: 91px;
    }

    .search-box {
        align-self: stretch;
        width: 100%;
    }

    /* Button text utilities */
    .btn-primary .mobile-text {
        display: inline;
    }

    .btn-primary .desktop-text {
        display: none;
    }

    /* Content components */
    .section-header-not-first {
        margin-top: 8px;
    }

    .section-area {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .section-area br {
        display: none;
    }

    .tag {
        margin-right: 0;
        margin-bottom: 0;
    }

    .bookmarklet-section {
        display: none;
    }

    /* Button hover states */
    .btn:hover {
        background-color: inherit;
    }

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

    .btn-secondary:hover {
        background-color: transparent;
    }

    .btn-secondary:disabled {
        background-color: var(--border) !important;
        opacity: 0.75;
        cursor: not-allowed;
    }

    .btn-success:hover {
        background-color: var(--success-color);
    }

    .btn-danger:hover {
        background-color: var(--danger-color);
    }

    /* Adjust spinner position on mobile */
    .spinner-overlay {
        padding-top: 190px;
    }
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 90px;
    z-index: 1000;
    margin-top: 1px;
    overflow: hidden;
}

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

.dropdown-item {
    display: block;
    padding: 8px 12px;
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

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

.dropdown-item:hover {
    background-color: var(--border);
}