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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #333;
}

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

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

header h1 {
    color: #333;
    font-size: 24px;
}

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

.mode-badge {
    padding: 6px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
}

.mode-read {
    background: #28a745;
    color: white;
}

.mode-edit {
    background: #ff9800;
    color: white;
}

.btn-logout-edit {
    background: #dc3545;
    color: white;
    padding: 6px 15px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.3s ease;
}

.btn-logout-edit:hover {
    background: #c82333;
}

/* Login */
.code-form-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.code-form {
    background: white;
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 100%;
}

.code-form h2 {
    margin-bottom: 15px;
    color: #333;
}

.code-form p {
    color: #666;
    margin-bottom: 20px;
}

.code-input {
    font-size: 24px;
    padding: 12px 20px;
    text-align: center;
    letter-spacing: 8px;
    border: 2px solid #ddd;
    border-radius: 8px;
    width: 100%;
    font-family: monospace;
}

.code-input:focus {
    border-color: #667eea;
    outline: none;
}

.btn-validate-code, .btn-cancel-code {
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
    display: inline-block;
    margin: 5px;
    border: none;
    cursor: pointer;
}

.btn-validate-code {
    background: #28a745;
    color: white;
}

.btn-cancel-code {
    background: #6c757d;
    color: white;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
}

/* Message */
.message {
    background: #d4edda;
    color: #155724;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #28a745;
}

/* Breadcrumb */
.breadcrumb {
    background: rgba(255, 255, 255, 0.9);
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.breadcrumb-link {
    text-decoration: none;
    color: #667eea;
}

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

.breadcrumb-current {
    color: #333;
    font-weight: 500;
}

/* Directories */
.directory-list {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.directory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.directory-header h2 {
    color: #333;
    border-left: 4px solid #667eea;
    padding-left: 15px;
}

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

.directory-card {
    background: #f8f9fa;
    border-radius: 10px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.directory-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.directory-card.has-videos {
    background: #e8f5e9;
    border-color: #4caf50;
}

.directory-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    text-decoration: none;
    color: #333;
}

.directory-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.directory-name {
    font-weight: 500;
    text-align: center;
    word-break: break-word;
}

.directory-badge {
    margin-top: 8px;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    background: #4caf50;
    color: white;
}

.no-directories {
    text-align: center;
    padding: 40px;
    color: #666;
    grid-column: 1 / -1;
}

/* Video Gallery */
.gallery {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.gallery-header h2 {
    color: #333;
    margin: 0;
}

.video-counter {
    background: #667eea;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 14px;
}

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

.back-link, .home-link, .mode-switch-edit {
    padding: 8px 15px;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.back-link {
    background: #6c757d;
    color: white;
}

.home-link {
    background: #667eea;
    color: white;
}

.mode-switch-edit {
    background: #ff9800;
    color: white;
}

.video-grid {
    display: grid;
    gap: 20px;
}

.video-item {
    text-align: center;
    transition: transform 0.3s ease;
    position: relative;
    background: #f8f9fa;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid transparent;
}

.video-item:hover {
    transform: scale(1.03);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.video-item.selected {
    border-color: #ff9800;
    background: #fff3e0;
}

.video-order {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    z-index: 5;
}

.video-link {
    text-decoration: none;
    display: block;
}

.video-thumbnail {
    position: relative;
    width: 100%;
    padding-bottom: 62.5%; /* 16:10 ratio */
    background: #1a1a2e;
    overflow: hidden;
}

.video-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    background: #2d2d44;
    color: white;
}

.video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    color: #333;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.video-item:hover .video-play-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.video-caption {
    padding: 10px;
    background: white;
}

.video-name {
    display: block;
    color: #333;
    font-weight: 500;
    word-break: break-all;
    font-size: 13px;
}

.video-size {
    display: block;
    color: #666;
    font-size: 11px;
    margin-top: 3px;
}

/* Mode Edit */
.edit-mode .video-item {
    cursor: pointer;
}

.selection-checkbox {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
}

.selection-checkbox input {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.edit-toolbar {
    background: #fff3e0;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.selection-controls, .action-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.selection-count {
    background: #ff9800;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
}

.btn-select-all, .btn-select-none, .btn-delete, .btn-copy, .btn-move {
    padding: 8px 15px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
}

.btn-select-all {
    background: #28a745;
    color: white;
}

.btn-select-none {
    background: #6c757d;
    color: white;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-copy {
    background: #17a2b8;
    color: white;
}

.btn-move {
    background: #ffc107;
    color: #333;
}

/* Video Player */
.video-player-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

.player-header h2 {
    color: #333;
    word-break: break-all;
}

.btn-player-nav {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-player-nav:hover {
    background: #5a6268;
}

.video-wrapper {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

.video-wrapper video {
    width: 100%;
    display: block;
    max-height: 70vh;
}

.player-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.btn-player {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease;
    font-size: 14px;
}

.btn-player:hover {
    background: #5a67d8;
}

.video-counter {
    color: #333;
    font-weight: 500;
}

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

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
}

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

.directory-tree-modal {
    margin: 20px 0;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
}

.tree-list {
    list-style: none;
    margin-left: 0;
}

.tree-list li {
    margin: 5px 0;
}

.tree-item {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.3s ease;
}

.tree-item:hover {
    background: #f0f0f0;
}

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

.selected-indicator {
    color: #4caf50;
    font-weight: bold;
    margin-left: auto;
}

.tree-children {
    margin-left: 25px;
}

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

.btn-cancel, .btn-validate {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.btn-cancel {
    background: #6c757d;
    color: white;
}

.btn-validate {
    background: #28a745;
    color: white;
}

/* Footer */
footer {
    margin-top: 30px;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    padding: 15px;
}

/* Responsive */
@media (max-width: 992px) {
    .video-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .video-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .directories-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .edit-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .selection-controls, .action-controls {
        justify-content: center;
    }
    
    .player-controls {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .video-grid {
        grid-template-columns: 1fr !important;
    }
    
    .video-thumbnail {
        padding-bottom: 56.25%;
    }
}