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

body {
    font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
    background: #f7f7f9;
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1002;
    background: #1177d1;
    border: none;
    border-radius: 4px;
    padding: 10px 15px;
    font-size: 20px;
    color: white;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.3s;
}

.sidebar-toggle:hover {
    background: #0d62ab;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.25);
}

/* Move toggle button when sidebar is open */
.sidebar.open ~ * .sidebar-toggle,
body.sidebar-open .sidebar-toggle {
    left: 340px;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: -320px;
    top: 0;
    width: 320px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    z-index: 1001;
    transition: left 0.3s ease;
    overflow-y: auto;
    border-right: 1px solid #ddd;
}

.sidebar.open {
    left: 0;
}

/* Backdrop when sidebar is open */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    transition: opacity 0.3s;
}

.sidebar-backdrop.show {
    display: block;
}

.sidebar-header {
    background: #1177d1;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 3px solid #0d62ab;
}

.sidebar-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.btn-close-sidebar {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
}

.btn-close-sidebar:hover {
    background: rgba(255,255,255,0.3);
}

.sidebar-content {
    padding: 15px;
}

/* Folder Tree */
.folder-tree {
    list-style: none;
}

.folder-item {
    margin: 5px 0;
}

.folder-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    color: #3a3a3a;
    text-decoration: none;
    user-select: none;
    border: 1px solid transparent;
}

.folder-link:hover {
    background: #f0f4f8;
    border-color: #d7e5f0;
}

.folder-link.active {
    background: #1177d1;
    color: white;
    font-weight: 500;
    border-color: #0d62ab;
}

.folder-icon {
    font-size: 16px;
    min-width: 20px;
}

.folder-name {
    flex: 1;
    font-size: 14px;
}

.folder-count {
    font-size: 11px;
    background: #e8eef3;
    padding: 2px 8px;
    border-radius: 12px;
    color: #555;
    font-weight: 600;
}

.folder-link.active .folder-count {
    background: rgba(255,255,255,0.3);
    color: white;
}

.subfolder-container {
    margin-left: 25px;
    margin-top: 5px;
    border-left: 2px solid #e0e0e0;
    padding-left: 10px;
}

.subfolder-item {
    margin: 3px 0;
}

.subfolder-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    color: #666;
    font-size: 13px;
    text-decoration: none;
    border: 1px solid transparent;
}

.subfolder-link:hover {
    background: #f8f9fa;
    color: #333;
    border-color: #e0e0e0;
}

.subfolder-link.active {
    background: #0f6cbf;
    color: white;
    border-color: #0d62ab;
}

.all-folders-link {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    transition: margin-left 0.3s ease;
    min-height: 100vh;
}

header {
    background: #1177d1;
    color: white;
    padding: 25px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 28px;
    font-weight: 600;
}

.header-info {
    display: flex;
    gap: 15px;
    align-items: center;
}

.controls {
    padding: 20px 30px;
    background: white;
    border-bottom: 1px solid #ddd;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 250px;
}

#search-input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
}

#search-input:focus {
    outline: none;
    border-color: #1177d1;
    box-shadow: 0 0 0 0.2rem rgba(17, 119, 209, 0.15);
}

.filter-section, .sort-section {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filter-section label, .sort-section label {
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

select:focus {
    outline: none;
    border-color: #1177d1;
    box-shadow: 0 0 0 0.2rem rgba(17, 119, 209, 0.15);
}

.view-section {
    display: flex;
    gap: 5px;
}

.btn-icon {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    color: #495057;
}

.btn-icon:hover {
    background: #f8f9fa;
    border-color: #1177d1;
    color: #1177d1;
}

.btn-icon.active {
    background: #1177d1;
    color: white;
    border-color: #1177d1;
}

.btn-secondary {
    padding: 8px 16px;
    background: white;
    color: #1177d1;
    border: 1px solid white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.95);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.loading {
    padding: 60px;
    text-align: center;
    font-size: 16px;
    color: #6c757d;
}

.protocols-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 30px;
    background: #f7f7f9;
}

.protocols-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 30px;
    background: #f7f7f9;
}

.btn-filter {
    padding: 8px 16px;
    background: white;
    color: #495057;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    font-size: 14px;
}

.btn-filter:hover {
    background: #f8f9fa;
    border-color: #1177d1;
    color: #1177d1;
}

.btn-filter.active {
    background: #ffc107;
    color: #212529;
    border-color: #ffc107;
}

.protocol-card {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 20px;
    padding-top: 50px; /* Space for favorite button */
    padding-right: 50px; /* Extra space on right to avoid overlap with favorite star */
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.protocol-card.outdated {
    background: #fff9e6;
    border-color: #ffc107;
}

.favorite-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
    padding: 5px;
    line-height: 1;
    border-radius: 4px;
}

.favorite-btn:hover {
    transform: scale(1.2);
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.protocol-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: #1177d1;
}

.protocol-card .icon {
    font-size: 40px;
    margin-bottom: 15px;
    display: block;
    color: #1177d1;
}

.protocol-card .name {
    font-weight: 600;
    font-size: 15px;
    color: #212529;
    margin-bottom: 10px;
    line-height: 1.4;
    word-break: break-word;
}

.protocol-card .folder {
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.protocol-card .info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #868e96;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e9ecef;
    flex-wrap: wrap;
    gap: 5px;
    margin-right: -30px; /* Compensate for extra right padding */
}

.protocol-card .date {
    font-weight: 500;
    color: #1177d1;
}

.protocol-card .date.outdated {
    color: #ff9800;
    font-weight: 600;
}

.protocol-card .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
    margin-right: -30px; /* Compensate for extra right padding */
    padding-right: 0;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    background: #e3f2fd;
    color: #1976d2;
}

.tag.auto-tag {
    background: #e8eaf6;
    color: #5c6bc0;
}

.tag.user-tag {
    background: #f3e5f5;
    color: #8e24aa;
}

.tag.outdated-badge {
    background: #fff3e0;
    color: #f57c00;
    border: 1px solid #ffb74d;
}

.tag-manager {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 5px;
}

.tag-input {
    padding: 3px 8px;
    border: 1px solid #ced4da;
    border-radius: 3px;
    font-size: 11px;
    width: 100px;
}

.btn-add-tag {
    padding: 3px 8px;
    background: #1177d1;
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-tag:hover {
    background: #0d62ab;
}

.btn-add-tag-inline {
    padding: 4px 10px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-add-tag-inline:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

.btn-add-tag-inline:active {
    transform: translateY(0);
}

.toggle-tag-btn {
    background: #e9ecef;
    color: #495057;
    border: 1px dashed #ced4da;
}

.toggle-tag-btn:hover {
    background: #dee2e6;
    border-color: #1177d1;
}

.tag-remove {
    margin-left: 4px;
    cursor: pointer;
    opacity: 0.6;
    font-weight: bold;
}

.tag-remove:hover {
    opacity: 1;
}

/* List View */
.protocols-list .protocol-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 15px 20px;
    padding-top: 15px;
    padding-right: 20px;
}

.protocols-list .protocol-card .favorite-btn {
    position: relative;
    top: auto;
    right: auto;
    order: -1; /* Move to the beginning */
    flex-shrink: 0;
    margin-right: 10px;
}

.protocols-list .protocol-card .icon {
    font-size: 30px;
    margin: 0;
    flex-shrink: 0;
}

.protocols-list .protocol-card .content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 20px;
    min-width: 0; /* Allow text truncation */
}

.protocols-list .protocol-card .name {
    flex: 1;
    margin: 0;
    min-width: 0; /* Allow text truncation */
}

.protocols-list .protocol-card .folder,
.protocols-list .protocol-card .info {
    margin: 0;
    border: none;
    padding: 0;
}

.protocols-list .protocol-card .tags {
    margin-right: 0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.75);
    animation: fadeIn 0.2s;
}

.modal.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 2% auto;
    width: 95%;
    max-width: 1200px;
    height: 90vh;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.2s;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

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

.modal-header {
    background: #1177d1;
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #0d62ab;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

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

.btn-close {
    background: white;
    color: #1177d1;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 18px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.btn-close:hover {
    background: #f0f0f0;
}

.modal-body {
    flex: 1;
    overflow: hidden;
    background: #f7f7f9;
}

#pdf-viewer {
    width: 100%;
    height: 100%;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 280px;
        left: -280px;
    }
    
    .sidebar-toggle {
        top: 15px;
        left: 15px;
        padding: 8px 12px;
        font-size: 18px;
    }
    
    /* Move toggle button when sidebar is open on mobile */
    body.sidebar-open .sidebar-toggle {
        left: 295px;
    }
    
    header h1 {
        font-size: 22px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-section, .sort-section {
        width: 100%;
    }
    
    .protocols-grid {
        grid-template-columns: 1fr;
        padding: 15px;
    }
    
    .modal-content {
        width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.empty-state .icon {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

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

.empty-state p {
    font-size: 16px;
}

/* Update Notification */
.update-notification {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    background: white;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: top 0.3s ease;
    border: 2px solid #1177d1;
}

.update-notification.show {
    top: 20px;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
}

.notification-icon {
    font-size: 24px;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.notification-text {
    font-size: 14px;
    color: #3a3a3a;
    font-weight: 500;
}

.btn-refresh {
    background: #1177d1;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-refresh:hover {
    background: #0d62ab;
}

.btn-dismiss {
    background: transparent;
    border: none;
    color: #868e96;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.btn-dismiss:hover {
    color: #495057;
}

/* Responsive notification */
@media (max-width: 768px) {
    .update-notification {
        width: 90%;
        max-width: 400px;
    }
    
    .notification-content {
        flex-wrap: wrap;
        padding: 12px 15px;
    }
    
    .notification-text {
        flex: 1 1 100%;
        margin-bottom: 8px;
    }
}
