/* =============================================================================
   FileChest - Main Stylesheet
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Base Styles
   ----------------------------------------------------------------------------- */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    padding: 20px;
    background: #f5f5f5;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 20px;
}

.container.wide {
    max-width: 1200px;
}

/* -----------------------------------------------------------------------------
   Header
   ----------------------------------------------------------------------------- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

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

.volume-selector {
    position: relative;
}

.volume-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 500;
    color: #333;
    transition: background 0.2s;
}

.volume-btn:hover {
    background: #eee;
}

.volume-icon {
    font-size: 1.2em;
}

.dropdown-arrow {
    font-size: 0.7em;
    color: #666;
    margin-left: 4px;
}

.volume-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    margin-top: 4px;
    overflow: hidden;
}

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

.volume-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: #333;
    text-decoration: none;
    transition: background 0.2s;
}

.volume-item:hover {
    background: #f5f5f5;
}

.volume-item.active {
    background: #e3f2fd;
    color: #1976d2;
}

.volume-item-icon {
    font-size: 1.1em;
}

.volume-item-name {
    font-weight: 500;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.user-info .username {
    color: #333;
    font-weight: 500;
}

.user-info a {
    padding: 6px 12px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 13px;
}

.user-info .btn-login {
    background: #1976d2;
    color: white;
}

.user-info .btn-login:hover {
    background: #1565c0;
}

.user-info .btn-logout {
    background: #eee;
    color: #333;
    border: none;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
}

.user-info .btn-logout:hover {
    background: #ddd;
}

/* -----------------------------------------------------------------------------
   Breadcrumb
   ----------------------------------------------------------------------------- */
.breadcrumb {
    margin-bottom: 15px;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 4px;
}

.breadcrumb a {
    color: #0066cc;
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb span {
    color: #666;
    margin: 0 5px;
}

/* -----------------------------------------------------------------------------
   Role Badge
   ----------------------------------------------------------------------------- */
.role-badge {
    display: inline-block;
    font-size: 0.85em;
    font-weight: normal;
    color: #666;
}

.role-viewer {
    color: #1976d2;
}

.role-editor {
    color: #388e3c;
}

/* -----------------------------------------------------------------------------
   Toolbar (Index page)
   ----------------------------------------------------------------------------- */
.toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    padding: 10px;
    background: #fafafa;
    border-radius: 4px;
    flex-wrap: wrap;
    align-items: center;
}

.toolbar button,
.toolbar label {
    padding: 8px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 14px;
}

.toolbar button:hover,
.toolbar label:hover {
    background: #f0f0f0;
}

.toolbar button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.toolbar button.danger {
    color: #d32f2f;
}

.toolbar button.danger:hover {
    background: #ffebee;
}

.toolbar .spacer {
    flex: 1;
}

.toolbar .separator {
    color: #ccc;
    margin: 0 4px;
}

.toolbar input[type="file"] {
    display: none;
}

/* -----------------------------------------------------------------------------
   File List (Index page)
   ----------------------------------------------------------------------------- */
.file-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.file-item:hover {
    background: #f9f9f9;
}

.file-item.selected {
    background: #e3f2fd;
}

.file-checkbox {
    margin-right: 10px;
    width: 18px;
    height: 18px;
}

.file-icon {
    width: 24px;
    margin-right: 10px;
    text-align: center;
}

.file-link {
    display: flex;
    align-items: center;
    flex: 1;
    color: #333;
    text-decoration: none;
}

.file-link:hover {
    color: #0066cc;
}

.file-name {
    flex: 1;
}

.file-actions {
    display: flex;
    gap: 5px;
}

.file-actions button {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: white;
    cursor: pointer;
    font-size: 12px;
}

.file-actions button:hover {
    background: #f0f0f0;
}

.file-size {
    width: 80px;
    text-align: right;
    color: #666;
    font-size: 0.9em;
}

.file-date {
    width: 150px;
    text-align: right;
    color: #666;
    font-size: 0.9em;
}

.empty {
    text-align: center;
    padding: 40px;
    color: #666;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    min-width: 300px;
    max-width: 500px;
}

.modal-content h3 {
    margin: 0 0 15px 0;
}

.modal-content input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 15px;
}

.modal-content select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 15px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.modal-buttons .btn-cancel {
    background: #eee;
}

.modal-buttons .btn-ok {
    background: #1976d2;
    color: white;
}

.modal-buttons .btn-danger {
    background: #d32f2f;
    color: white;
}

.modal-buttons .btn-secondary {
    background: #ff9800;
    color: white;
}

/* Error list in modal */
.error-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 0 0 15px 0;
    padding: 0 0 0 20px;
    color: #d32f2f;
}

.error-list li {
    margin-bottom: 8px;
    word-break: break-all;
}

/* -----------------------------------------------------------------------------
   Upload Modal
   ----------------------------------------------------------------------------- */
.modal-upload-content {
    max-width: 550px;
    width: 90%;
}

.upload-file-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 15px;
    background: #fafafa;
}

.upload-file-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

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

.upload-file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-file-size {
    color: #666;
    margin-left: 10px;
    flex-shrink: 0;
}

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

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

.form-group label.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
}

.form-group label.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.upload-error {
    color: #d32f2f;
    background: #ffebee;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 14px;
    display: none;
}

.upload-error.active {
    display: block;
}

/* -----------------------------------------------------------------------------
   Toast Notifications
   ----------------------------------------------------------------------------- */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 4px;
    color: white;
    z-index: 1001;
    display: none;
}

.toast.success {
    background: #388e3c;
}

.toast.error {
    background: #d32f2f;
}

.toast.active {
    display: block;
}

/* -----------------------------------------------------------------------------
   Drag & Drop
   ----------------------------------------------------------------------------- */
.drop-zone {
    border: 2px dashed transparent;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.drop-zone.drag-over {
    border-color: #1976d2;
    background: #e3f2fd;
}

.drop-zone.drag-over * {
    pointer-events: none;
}

/* -----------------------------------------------------------------------------
   Upload Progress
   ----------------------------------------------------------------------------- */
.upload-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1002;
}

.upload-overlay.active {
    display: flex;
}

.upload-progress {
    background: white;
    padding: 30px;
    border-radius: 8px;
    min-width: 350px;
    text-align: center;
}

.upload-progress h3 {
    margin: 0 0 15px 0;
}

.progress-bar {
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-bar-fill {
    height: 100%;
    background: #1976d2;
    width: 0%;
    transition: width 0.2s ease;
}

.progress-text {
    color: #666;
    font-size: 14px;
}

/* -----------------------------------------------------------------------------
   Preview Page - File Header
   ----------------------------------------------------------------------------- */
.file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.file-header h2 {
    margin: 0;
    font-size: 1.2em;
    word-break: break-all;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.header-actions a,
.header-actions button {
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid #ddd;
}

.btn-back {
    background: #f5f5f5;
    color: #333;
}

.btn-back:hover {
    background: #e0e0e0;
}

.btn-download {
    background: #1976d2;
    color: white;
    border: none;
}

.btn-download:hover {
    background: #1565c0;
}

/* -----------------------------------------------------------------------------
   Preview Page - File Metadata
   ----------------------------------------------------------------------------- */
.file-meta {
    display: flex;
    gap: 20px;
    padding: 10px 15px;
    background: #fafafa;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #666;
    flex-wrap: wrap;
}

.file-meta strong {
    color: #333;
}

/* -----------------------------------------------------------------------------
   Preview Page - Preview Container
   ----------------------------------------------------------------------------- */
.preview-container {
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    background: #fafafa;
    min-height: 200px;
}

/* Image preview */
.preview-image {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: #f0f0f0;
}

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

/* Video/Audio preview */
.preview-video,
.preview-audio {
    display: flex;
    justify-content: center;
    padding: 20px;
}

.preview-video video {
    max-width: 100%;
    max-height: 80vh;
}

.preview-audio audio {
    width: 100%;
    max-width: 600px;
}

/* Text preview */
.preview-text {
    padding: 0;
    background: #1e1e1e;
    color: #d4d4d4;
    overflow: auto;
    max-height: 80vh;
}

.preview-text pre {
    margin: 0;
    padding: 15px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    text-align: left;
}

.preview-text .loading {
    padding: 40px;
    text-align: center;
    color: #888;
}

/* PDF preview */
.preview-pdf {
    height: 80vh;
}

.preview-pdf iframe,
.preview-pdf embed {
    width: 100%;
    height: 100%;
    border: none;
}

/* Unknown/no preview */
.preview-unknown {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px 20px;
    color: #666;
}

.preview-unknown .icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.preview-unknown p {
    margin: 0 0 20px 0;
}

/* -----------------------------------------------------------------------------
   Footer
   ----------------------------------------------------------------------------- */
.footer {
    text-align: center;
    padding: 20px;
    color: #999;
    font-size: 0.85em;
    margin-top: 20px;
}

.footer p {
    margin: 5px 0;
}

.footer a {
    color: #666;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}
