/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --danger-color: #e74c3c;
    --dark-color: #34495e;
    --light-color: #ecf0f1;
    --text-color: #2c3e50;
    --border-color: #ddd;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --bg-color: #f5f7fa;
    --card-bg-color: #ffffff;
    --card-hover-bg: #f9f9f9;
}

html[data-theme="dark"] {
    --primary-color: #2980b9;
    --secondary-color: #27ae60;
    --danger-color: #c0392b;
    --dark-color: #2c3e50;
    --light-color: #34495e;
    --text-color: #ecf0f1;
    --border-color: #4a5568;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    --bg-color: #1a202c;
    --card-bg-color: #2d3748;
    --card-hover-bg: #3a4a5e;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
    line-height: 1.6;
    transition: background-color 0.3s ease;
}

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

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

header h1 {
    font-size: 28px;
    color: var(--primary-color);
}

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

.search-container {
    display: flex;
    width: 300px;
}

.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 38px;
    height: 38px;
    transition: background-color 0.2s;
}

.theme-toggle:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

html[data-theme="dark"] .theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

#search-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px 0 0 4px;
    outline: none;
}

#search-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
}

/* Main Layout */
main {
    display: flex;
    gap: 30px;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background-color: var(--card-bg-color);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.content {
    flex-grow: 1;
    background-color: var(--card-bg-color);
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
}

/* Sidebar Styles */
.sidebar h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--dark-color);
}

#categories-list {
    list-style: none;
    margin-bottom: 30px;
}

#categories-list li {
    padding: 10px 15px;
    margin-bottom: 5px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
}

#categories-list li:hover {
    background-color: #f0f0f0;
}

#categories-list li.active {
    background-color: var(--primary-color);
    color: white;
}

#tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 30px;
}

.tag {
    background-color: #f0f0f0;
    color: var(--dark-color);
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.tag:hover {
    background-color: #e0e0e0;
}

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

.primary-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    font-weight: 500;
    transition: background-color 0.2s;
}

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

/* Toolbar Styles */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

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

.view-options button {
    background-color: #f0f0f0;
    border: none;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
}

.view-options button.active {
    background-color: var(--primary-color);
    color: white;
}

#sort-select {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    outline: none;
}

/* Files Container Styles */
#files-container {
    min-height: 300px;
}

.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.list-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.file-card {
    background-color: var(--card-hover-bg);
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.file-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

.file-icon {
    font-size: 40px;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.file-card.presentation .file-icon {
    color: #e67e22;
}

.file-card.document .file-icon {
    color: var(--primary-color);
}

.file-card.spreadsheet .file-icon {
    color: var(--secondary-color);
}

.file-card.image .file-icon {
    color: #9b59b6;
}

.file-name {
    font-weight: 500;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-date {
    font-size: 12px;
    color: #888;
}

.file-tags {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.file-tag {
    font-size: 10px;
    background-color: #f0f0f0;
    padding: 2px 6px;
    border-radius: 10px;
}

/* List View Specific Styles */
.list-view .file-card {
    display: flex;
    align-items: center;
    padding: 10px 15px;
}

.list-view .file-icon {
    margin-right: 15px;
    margin-bottom: 0;
}

.list-view .file-info {
    flex-grow: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-view .file-main-info {
    flex-grow: 1;
}

.list-view .file-tags {
    margin-top: 0;
    margin-left: 20px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
}

.modal-content {
    background-color: var(--card-bg-color);
    margin: 50px auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.modal-content.large {
    max-width: 800px;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: #888;
}

.modal h2 {
    margin-bottom: 20px;
    color: var(--dark-color);
}

/* Preview Styles */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    color: var(--primary-color);
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

html[data-theme="dark"] .icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.preview-content {
    min-height: 300px;
    border: 1px solid var(--border-color);
    padding: 20px;
    margin-bottom: 20px;
    overflow: auto;
    background-color: var(--bg-color);
}

/* Fullscreen Preview */
.fullscreen-preview {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    z-index: 2000;
    padding: 20px;
}

.exit-fullscreen {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2001;
    background-color: var(--card-bg-color);
    box-shadow: var(--shadow);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.fullscreen-content {
    width: 100%;
    height: calc(100% - 40px);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
}

.fullscreen-content img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
}

.fullscreen-content iframe {
    width: 95%;
    height: 95%;
    border: none;
}

.fullscreen-content .document-preview,
.fullscreen-content .spreadsheet-preview,
.fullscreen-content .image-preview {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.fullscreen-content img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
}

.fullscreen-content iframe {
    width: 95%;
    height: 95%;
    border: none;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    outline: none;
}

/* File Preview Styles */
.file-details {
    background-color: var(--card-hover-bg);
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.preview-content {
    min-height: 300px;
    border: 1px solid var(--border-color);
    padding: 20px;
    margin-bottom: 20px;
    overflow: auto;
    background-color: var(--bg-color);
}

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

.image-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    min-height: 300px;
}

.image-preview img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
}

.document-preview, .spreadsheet-preview {
    height: 500px;
}

.document-preview iframe, .spreadsheet-preview iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.fallback-preview {
    padding: 20px;
    text-align: center;
    color: var(--text-color);
}

.generic-preview {
    text-align: center;
    padding: 50px 20px;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.secondary-btn {
    padding: 10px 15px;
    background-color: #f0f0f0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

.danger-btn {
    padding: 10px 15px;
    background-color: var(--danger-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
    main {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        margin-bottom: 20px;
    }

    header {
        flex-direction: column;
        align-items: stretch;
    }

    header h1 {
        margin-bottom: 15px;
    }

    .search-container {
        width: 100%;
    }
    
    .grid-view {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 0;
    color: #888;
}

.empty-state i {
    font-size: 50px;
    margin-bottom: 20px;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.file-card {
    animation: fadeIn 0.3s ease-out;
}
