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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #2c3e50;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

header p {
    color: #7f8c8d;
    font-size: 1.1em;
}

main {
    max-width: 1400px;
    margin: 0 auto;
}

.loading, .error {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 8px;
    margin-bottom: 20px;
}

.error {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.stats {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: center;
    color: #666;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.stats strong {
    color: #667eea;
    font-weight: 700;
}

#tags-container {
    margin-bottom: 20px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.tag-search-section {
    margin-bottom: 20px;
}

#tag-search {
    width: 100%;
    padding: 12px 18px;
    font-size: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: white;
    transition: all 0.3s ease;
}

#tag-search:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    min-height: 20px;
}

.selected-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    animation: slideIn 0.2s ease-out;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.selected-tag .remove-tag {
    cursor: pointer;
    font-weight: bold;
    padding: 0 4px;
    border-radius: 50%;
    transition: background 0.2s;
}

.selected-tag .remove-tag:hover {
    background: rgba(255,255,255,0.2);
}

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

.available-tags-section {
    padding-top: 15px;
    border-top: 1px solid #ecf0f1;
}

.available-tags-section label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: #555;
    font-size: 0.95em;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    display: inline-block;
    padding: 8px 16px;
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.tag:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.tag.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Bulk Actions Bar */
#bulk-actions-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    padding: 16px 20px;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.bulk-actions-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

#bulk-selected-count {
    font-weight: 700;
    color: #667eea;
    min-width: 100px;
}

#bulk-tags-input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
}

#bulk-tags-input:focus {
    outline: none;
    border-color: #667eea;
}

.bulk-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 14px;
    transition: all 0.3s;
}

.bulk-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.bulk-btn-secondary {
    background: #e0e0e0;
    color: #2c3e50;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
}

.bulk-btn-secondary:hover {
    background: #d0d0d0;
}

/* Card Grid Layout */
#documents-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.document-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
}

.document-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.document-card.selected {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

.document-checkbox {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: #667eea;
}

.document-thumbnail {
    width: 100%;
    height: 140px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.document-thumbnail.pdf { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.document-thumbnail.doc { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.document-thumbnail.docx { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.document-thumbnail.xls { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.document-thumbnail.xlsx { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.document-thumbnail.txt { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.document-thumbnail.zip { background: linear-gradient(135deg, #30cfd0 0%, #330867 100%); }
.document-thumbnail.image { background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); }

.document-thumbnail .file-icon {
    font-size: 48px;
    color: white;
    opacity: 0.9;
}

.document-type-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
}

.document-info {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.document-name {
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 6px;
    font-size: 0.85em;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.document-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.75em;
    color: #7f8c8d;
    margin-bottom: 8px;
}

.document-meta-row {
    display: flex;
    justify-content: space-between;
}

.document-views {
    color: #667eea;
    font-weight: 600;
}

.document-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: auto;
}

.document-tag {
    display: inline-block;
    padding: 3px 8px;
    background: linear-gradient(135deg, #f093fb20 0%, #f5576c20 100%);
    color: #764ba2;
    border-radius: 10px;
    font-size: 0.7em;
    border: 1px solid #f093fb40;
    font-weight: 600;
}

.document-actions {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #f0f0f0;
    margin-top: auto;
}

.doc-action-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.doc-action-open {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.doc-action-open:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.doc-action-download {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.doc-action-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(240, 147, 251, 0.4);
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 12px;
    color: #95a5a6;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: white;
    font-size: 0.9em;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }
    
    #documents-container {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }
    
    .document-thumbnail {
        height: 120px;
    }
    
    .document-thumbnail .file-icon {
        font-size: 40px;
    }
}

@media (max-width: 480px) {
    #documents-container {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}
