/**
 * Main Stylesheet - Modular CSS Architecture
 * Organized into reusable component files for better maintainability
 * See css/README.md for documentation
 */

/* Theme variables and design tokens */
@import './components/theme.css';

/* Base styles: reset, typography, layout */
@import './components/base.css';

/* Component-specific styles */
@import './components/auth.css';
@import './components/header.css';
@import './components/bookmarks.css';
@import './components/modal.css';

/* 
 * Modular component styles are imported above via @import statements.
 * All styles are now organized in css/components/ directory.
 * Do not add CSS here - add to appropriate component files instead.
 * See css/README.md for documentation.
 */

.sidebar-nav {
    flex: 1;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
}

.nav-item {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 12px 20px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-info {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    overflow: hidden;
    text-overflow: ellipsis;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.page {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: auto;
}

/* Authentication */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
}

.auth-container h2 {
    font-size: 32px;
    margin-bottom: 10px;
}

.auth-container p {
    color: #666;
    margin-bottom: 30px;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
}

.auth-tab {
    background: none;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    color: #999;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.auth-tab.active {
    color: #2c3e50;
    border-bottom-color: #2c3e50;
}

.auth-form {
    display: none;
    width: 100%;
    max-width: 350px;
}

.auth-form.active {
    display: block;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 5px;
    color: #333;
}

.form-group input,
.form-group textarea {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    width: 100%;
    min-width: 0;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

/* Buttons */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

/* App Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
    border-bottom: 1px solid #e7edf3;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.header-left h2 {
    font-size: 24px;
    color: #2c3e50;
}

.header-right {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.search-box {
    min-width: 240px;
    padding: 10px 14px;
    border: 1px solid #d9e2ec;
    border-radius: 999px;
    width: 260px;
    font-size: 14px;
    background: #fff;
    color: #243447;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.search-box:focus {
    outline: none;
    border-color: #5b8def;
    box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.16);
    transform: translateY(-1px);
}

#sortOrder {
    min-width: 150px;
    padding: 10px 38px 10px 14px;
    border: 1px solid #d9e2ec;
    border-radius: 999px;
    font-size: 14px;
    color: #243447;
    background-color: #fff;
    background-image: linear-gradient(45deg, transparent 50%, #64748b 50%), linear-gradient(135deg, #64748b 50%, transparent 50%), linear-gradient(to right, #eef2f7, #eef2f7);
    background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px), calc(100% - 2.25rem) 0.45rem;
    background-size: 6px 6px, 6px 6px, 1px calc(100% - 0.9rem);
    background-repeat: no-repeat;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

#sortOrder:focus {
    outline: none;
    border-color: #5b8def;
    box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.16);
    transform: translateY(-1px);
}

#sortOrder:hover,
.search-box:hover {
    border-color: #b8c7d9;
}

/* Bookmarks List */
.bookmarks-list {
    list-style: none;
    padding: 20px;
    margin: 0 auto;
    max-width: 900px;
}

.bookmarks-list .bookmark-item {
    display: block;
    margin-bottom: 12px;
}

.bookmark-card {
    background: white;
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: 0 6px 18px rgba(16,24,40,0.06);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    width: 100%;
}

.bookmark-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 22px rgba(16,24,40,0.07);
}

.bookmark-card-skeleton {
    pointer-events: none;
}

.skeleton {
    position: relative;
    overflow: hidden;
    background: #e7edf3;
    border-radius: 6px;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    animation: skeletonShimmer 1.2s infinite;
}

.skeleton-title {
    height: 20px;
    width: 72%;
    margin-bottom: 10px;
}

.skeleton-url {
    height: 12px;
    width: 38%;
    margin-bottom: 14px;
}

.skeleton-line {
    height: 14px;
    width: 100%;
    margin-bottom: 8px;
}

.skeleton-line-short {
    width: 82%;
}

.skeleton-pill {
    display: inline-block;
    width: 72px;
    height: 24px;
    margin-bottom: 10px;
}

.bookmark-card-skeleton .bookmark-actions button {
    color: transparent;
    background: #eef2f6;
    border-color: #eef2f6;
}

@keyframes skeletonShimmer {
    100% {
        transform: translateX(100%);
    }
}

.bookmark-header > div {
    flex: 1;
    min-width: 0;
}

.bookmark-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.bookmark-main {
    flex: 1;
    min-width: 0;
}

.bookmark-title {
    font-weight: 600;
    font-size: 15px;
    color: #2c3e50;
    margin-bottom: 5px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.bookmark-url {
    font-size: 12px;
    color: #3498db;
    text-decoration: none;
    display: block;
    margin-bottom: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bookmark-url:hover {
    text-decoration: underline;
}

.bookmark-description {
    font-size: 13px;
    color: #666;
    margin-bottom: 10px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.bookmark-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}

.tag {
    background: #ecf0f1;
    color: #34495e;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.tag:hover {
    background: #bdc3c7;
}

.bookmark-actions {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex-shrink: 0;
    opacity: 0.9;
    transition: opacity 0.12s ease;
    max-width: max-content;
}

.bookmark-item:hover .bookmark-actions {
    opacity: 1;
}

.icon-btn {
    width: 36px;          /* fixed compact size */
    height: 36px;
    padding: 6px;         /* comfortable touch target */
    flex: 0 0 auto;       /* prevent flex growth */
    background: #fff;
    border: 1px solid rgba(16,24,40,0.04);
    border-radius: 6px;
}

.icon-btn img {
    width: 16px;
    height: 16px;
    opacity: 0.75;
    transition: all 0.2s ease;
}

/* hover states */
.icon-btn:hover {
    background: #f0f1f3;
}

.icon-btn:hover img {
    opacity: 1;
}

.icon-btn:active {
    background: #e0e4ea;
}

.delete-btn:hover {
    background: #ffeaea;
}

.copy-link-btn {
    padding: 2px 4px;
    font-size: 16px;
    background: #f0f1f3;
    border: 1px solid #d9e2ec;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.copy-link-btn:hover {
    background: #e8eaed;
    border-color: #b8c7d9;
}

.copy-link-btn:active {
    background: #dce0e8;
}

.bookmark-actions button {
    flex: 0 0 auto;
    padding: 6px;
    font-size: 13px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.12s ease, transform 0.08s ease;
}

/* Compact mode: reduce paddings and badge size */
/* compact-mode rules removed (feature disabled) */

.bookmark-actions button:hover {
    background: #f9f9f9;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    flex-wrap: wrap;
}

.pagination button {
    min-width: 40px;
    padding: 8px 12px;
    border: 1px solid #d9e2ec;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    color: #334155;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.pagination button.active {
    background: linear-gradient(180deg, #5b8def 0%, #4478e3 100%);
    color: white;
    border-color: #4478e3;
    box-shadow: 0 8px 18px rgba(68, 120, 227, 0.25);
}

.pagination button:hover {
    transform: translateY(-1px);
    border-color: #9fb4cf;
    box-shadow: 0 6px 12px rgba(15, 23, 42, 0.08);
}

/* Tags List */
.tags-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    padding: 20px;
}

.tag-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.2s;
}

.tag-item:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.tag-item-name {
    font-weight: 600;
    font-size: 16px;
    color: #2c3e50;
}

.tag-item-count {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}

/* Settings */
.settings-section {
    padding: 20px;
    background: white;
    margin: 20px;
    border-radius: 8px;
}

.settings-section h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.settings-actions {
    display: flex;
    gap: 10px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 18px;
    color: #2c3e50;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.modal-close:hover {
    color: #333;
}

#bookmarkForm {
    padding: 20px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 20px;
}

.modal-footer .btn,
.modal-footer .modal-close {
    min-width: 92px;
    height: 42px;
}

.modal-footer .modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    font-size: 14px;
    border-radius: 4px;
    color: #555;
    background: #f3f4f6;
}

.modal-footer .modal-close:hover {
    background: #e5e7eb;
    color: #222;
}

/* Tag suggestions dropdown (custom) */
.tag-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    z-index: 1500;
    max-height: 180px;
    overflow: auto;
    margin-top: 6px;
}

.tag-suggestion-item {
    padding: 8px 10px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.tag-suggestion-item:hover,
.tag-suggestion-item.active {
    background: #f3f6fa;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.alert-error {
    background: #fee;
    color: #c33;
}

.alert-success {
    background: #efe;
    color: #3c3;
}

.alert-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 16px;
    border-radius: 4px;
    background: #333;
    color: white;
    z-index: 2000;
    display: none;
    animation: slideIn 0.3s ease-out;
}

.alert-toast.show {
    display: block;
}

@keyframes slideIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Views */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .icon-btn {
        width: 28px;
        height: 28px;
    }

    .icon-btn img {
        width: 14px;
        height: 14px;
    }

    .bookmark-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .bookmark-actions {
        margin-top: 6px;
        opacity: 1; /* always visible on mobile */
        flex-direction: row;
        justify-content: flex-end;
        gap: 8px;
        flex-wrap: wrap;
    }

    .bookmarks-list {
        max-width: 100%;
    }

    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex-direction: column;
        height: auto;
    }

    .sidebar-header {
        padding: 12px 16px 8px;
    }

    .sidebar-header h1 {
        font-size: 20px;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 12px;
    }

    .sidebar-footer {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        border-top: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        gap: 10px;
        padding: 10px 12px;
    }

    .nav-item {
        flex: 1 1 calc(33.333% - 8px);
        min-width: 0;
        text-align: center;
        padding: 8px 10px;
        font-size: 13px;
        border-radius: 6px;
    }

    .user-info {
        font-size: 11px;
    }

    #logoutBtn {
        padding: 8px 12px;
        font-size: 13px;
        white-space: nowrap;
    }

    .main-content {
        min-width: 0;
    }

    .app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .header-right {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .search-box {
        width: 100%;
        min-width: 0;
    }

    #sortOrder {
        width: 100%;
        min-width: 0;
    }

    .bookmarks-list {
        padding: 12px;
        max-width: 100%;
    }

    .bookmark-actions button {
        width: auto;
        padding: 6px 8px;
        font-size: 13px;
    }

    .bookmark-card {
        padding: 10px 12px;
    }

    .skeleton-title {
        width: 80%;
    }

    .skeleton-url {
        width: 55%;
    }

    .modal {
        align-items: flex-start;
        padding: 8px;
    }

    .modal-content {
        width: 100%;
        max-width: none;
        max-height: calc(100vh - 16px);
        border-radius: 12px;
    }

    #bookmarkForm {
        padding: 16px;
    }

    .modal-header,
    .modal-footer {
        padding-left: 16px;
        padding-right: 16px;
    }

    .modal-footer {
        gap: 8px;
    }

    .modal-footer .btn,
    .modal-footer .modal-close {
        flex: 1;
        min-width: 0;
    }
}
