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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #0f1419;
    color: #e1e8ed;
    line-height: 1.6;
}

/* Container and Layout */
.container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #1a1f2e 0%, #16213e 100%);
    border-right: 1px solid #2d3748;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #2d3748;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    color: #4299e1;
    font-size: 1.25rem;
    font-weight: 600;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #a0aec0;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background: rgba(66, 153, 225, 0.1);
    color: #4299e1;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0;
}

.sidebar-menu li {
    margin: 0.25rem 0;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: #a0aec0;
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
}

.sidebar-menu a:hover {
    background: rgba(66, 153, 225, 0.1);
    color: #4299e1;
    border-right: 3px solid #4299e1;
}

.sidebar-menu a.active {
    background: rgba(66, 153, 225, 0.2);
    color: #4299e1;
    border-right: 3px solid #4299e1;
}

/* Main Content */
.main-content {
    margin-left: 260px;
    flex: 1;
    min-height: 100vh;
    background: #0f1419;
}

.top-bar {
    background: #1a202c;
    border-bottom: 1px solid #2d3748;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar h1 {
    color: #e1e8ed;
    font-size: 1.75rem;
    font-weight: 600;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-indicator {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-indicator.online {
    background: rgba(72, 187, 120, 0.2);
    color: #48bb78;
    border: 1px solid rgba(72, 187, 120, 0.3);
}

.content {
    padding: 2rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    background: transparent;
    color: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(66, 153, 225, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
    box-shadow: 0 4px 8px rgba(66, 153, 225, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #4a5568;
    color: #e1e8ed;
    border: 1px solid #718096;
}

.btn-secondary:hover {
    background: #2d3748;
    border-color: #4a5568;
}

.btn-danger {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(229, 62, 62, 0.3);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #c53030 0%, #9c2a2a 100%);
    box-shadow: 0 4px 8px rgba(229, 62, 62, 0.4);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(72, 187, 120, 0.3);
}

.btn-success:hover {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    box-shadow: 0 4px 8px rgba(72, 187, 120, 0.4);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.btn-icon {
    padding: 0.5rem;
    border-radius: 6px;
    background: rgba(160, 174, 192, 0.1);
    border: 1px solid rgba(160, 174, 192, 0.2);
    color: #a0aec0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(66, 153, 225, 0.2);
    border-color: #4299e1;
    color: #4299e1;
}

.btn-icon.btn-danger {
    color: #e53e3e;
    border-color: rgba(229, 62, 62, 0.3);
}

.btn-icon.btn-danger:hover {
    background: rgba(229, 62, 62, 0.2);
    border-color: #e53e3e;
}

.btn-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: #a0aec0;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-close:hover {
    background: rgba(229, 62, 62, 0.2);
    color: #e53e3e;
}

/* Cards */
.card {
    background: #1a202c;
    border: 1px solid #2d3748;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.card:hover {
    border-color: #4a5568;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* Dashboard Styles */
.dashboard-grid {
    display: grid;
    gap: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    border: 1px solid #4a5568;
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border-color: #4299e1;
}

.stat-card.online {
    border-color: rgba(72, 187, 120, 0.5);
    background: linear-gradient(135deg, #1a202c 0%, rgba(72, 187, 120, 0.1) 100%);
}

.stat-icon {
    font-size: 2rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(66, 153, 225, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(66, 153, 225, 0.2);
}

.stat-content h3 {
    font-size: 2rem;
    font-weight: 700;
    color: #4299e1;
    margin-bottom: 0.25rem;
}

.stat-content p {
    color: #a0aec0;
    font-size: 0.875rem;
    font-weight: 500;
}

.section {
    margin-bottom: 2rem;
}

.section h2 {
    color: #e1e8ed;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.device-card {
    background: #1a202c;
    border: 1px solid #2d3748;
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.2s ease;
}

.device-card:hover {
    border-color: #4a5568;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.device-header h3 {
    color: #e1e8ed;
    font-size: 1.125rem;
    font-weight: 600;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-badge.online {
    background: rgba(72, 187, 120, 0.2);
    color: #48bb78;
    border: 1px solid rgba(72, 187, 120, 0.3);
}

.status-badge.offline {
    background: rgba(160, 174, 192, 0.2);
    color: #a0aec0;
    border: 1px solid rgba(160, 174, 192, 0.3);
}

.status-badge.active {
    background: rgba(72, 187, 120, 0.2);
    color: #48bb78;
    border: 1px solid rgba(72, 187, 120, 0.3);
}

.status-badge.inactive {
    background: rgba(229, 62, 62, 0.2);
    color: #e53e3e;
    border: 1px solid rgba(229, 62, 62, 0.3);
}

.device-info p {
    color: #a0aec0;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.device-info strong {
    color: #e1e8ed;
}

/* Media Manager Styles */
.upload-area {
    border: 2px dashed #4a5568;
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(26, 32, 44, 0.5);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: #4299e1;
    background: rgba(66, 153, 225, 0.1);
    transform: scale(1.02);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.upload-icon {
    font-size: 3rem;
    color: #4299e1;
}

.upload-hint {
    color: #a0aec0;
    font-size: 0.875rem;
}

.upload-progress {
    margin-top: 1rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #2d3748;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4299e1, #3182ce);
    transition: width 0.3s ease;
}

.search-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-input, .filter-select {
    padding: 0.75rem 1rem;
    border: 1px solid #2d3748;
    border-radius: 8px;
    background: #1a202c;
    color: #e1e8ed;
    font-size: 0.875rem;
}

.search-input {
    flex: 1;
}

.search-input:focus, .filter-select:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.media-card {
    background: #1a202c;
    border: 1px solid #2d3748;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.media-card:hover {
    border-color: #4a5568;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.media-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(45, 55, 72, 0.5);
}

.media-icon {
    font-size: 1.5rem;
}

.media-actions {
    display: flex;
    gap: 0.5rem;
}

.media-content {
    padding: 1rem;
}

.media-content h3 {
    color: #e1e8ed;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.media-filename {
    color: #a0aec0;
    font-size: 0.75rem;
    margin-bottom: 0.75rem;
    font-family: monospace;
}

.media-info {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.file-type, .file-size, .duration {
    padding: 0.25rem 0.5rem;
    background: rgba(66, 153, 225, 0.1);
    border: 1px solid rgba(66, 153, 225, 0.2);
    border-radius: 6px;
    font-size: 0.75rem;
    color: #4299e1;
}

.upload-date {
    color: #a0aec0;
    font-size: 0.75rem;
}

/* Playlist Styles */
.playlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.playlist-card {
    background: #1a202c;
    border: 1px solid #2d3748;
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.2s ease;
}

.playlist-card:hover {
    border-color: #4a5568;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.playlist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.playlist-header h3 {
    color: #e1e8ed;
    font-size: 1.125rem;
    font-weight: 600;
}

.playlist-actions {
    display: flex;
    gap: 0.5rem;
}

.playlist-description {
    color: #a0aec0;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.playlist-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.created-date {
    color: #a0aec0;
    font-size: 0.75rem;
}

/* Device Manager Styles */
.device-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.device-item {
    background: #1a202c;
    border: 1px solid #2d3748;
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.device-item:hover {
    border-color: #4a5568;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.device-actions {
    display: flex;
    gap: 0.75rem;
}

.info-card {
    background: #1a202c;
    border: 1px solid #2d3748;
    border-radius: 12px;
    padding: 1.5rem;
}

.info-card h3 {
    color: #e1e8ed;
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.info-card ol {
    color: #a0aec0;
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
}

.info-card li {
    margin-bottom: 0.5rem;
}

.url-display {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 8px;
    padding: 1rem;
}

.url-display code {
    flex: 1;
    color: #4299e1;
    font-family: monospace;
    font-size: 0.875rem;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    background: #1a202c;
    border: 1px solid #2d3748;
    border-radius: 12px;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    color: #e1e8ed;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: #a0aec0;
    font-size: 0.875rem;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #1a202c;
    border: 1px solid #2d3748;
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    position: relative;
}

.modal-header h3 {
    color: #e1e8ed;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    color: #e1e8ed;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #2d3748;
    border-radius: 8px;
    background: #2d3748;
    color: #e1e8ed;
    font-size: 0.875rem;
}

.form-input:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
}

/* Playlist Editor */
.playlist-editor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 1rem;
}

.media-library-section,
.current-playlist-section {
    background: #2d3748;
    border-radius: 8px;
    padding: 1rem;
}

.media-library-section h4,
.current-playlist-section h4 {
    color: #e1e8ed;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.media-list,
.playlist-items {
    max-height: 400px;
    overflow-y: auto;
}

.media-item,
.playlist-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: #1a202c;
    border: 1px solid #4a5568;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.media-item:hover,
.playlist-item:hover {
    border-color: #4299e1;
    background: rgba(66, 153, 225, 0.1);
}

.media-icon {
    font-size: 1.25rem;
    width: 32px;
    text-align: center;
}

.media-info {
    flex: 1;
}

.media-title {
    color: #e1e8ed;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.media-details {
    color: #a0aec0;
    font-size: 0.75rem;
}

.error-message {
    color: #e53e3e;
    background: rgba(229, 62, 62, 0.1);
    border: 1px solid rgba(229, 62, 62, 0.3);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    margin: 1rem 0;
}

.empty-message {
    color: #a0aec0;
    text-align: center;
    padding: 2rem;
    font-style: italic;
}

.drag-handle {
    cursor: move;
    color: #a0aec0;
    font-size: 1rem;
    padding: 0.25rem;
}

.drag-handle:hover {
    color: #4299e1;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.toast.success {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

.toast.error {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
}

.toast.info {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Activity Log */
.activity-log {
    background: #1a202c;
    border: 1px solid #2d3748;
    border-radius: 12px;
    padding: 1.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #2d3748;
}

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

.activity-time {
    color: #a0aec0;
    font-size: 0.75rem;
    font-family: monospace;
    min-width: 60px;
}

.activity-text {
    color: #e1e8ed;
    font-size: 0.875rem;
    flex: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .device-grid {
        grid-template-columns: 1fr;
    }
    
    .media-grid {
        grid-template-columns: 1fr;
    }
    
    .playlist-grid {
        grid-template-columns: 1fr;
    }
    
    .playlist-editor {
        grid-template-columns: 1fr;
    }
    
    .search-controls {
        flex-direction: column;
    }
    
    .device-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .device-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
    
    .top-bar {
        padding: 1rem;
    }
    
    .content {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .top-bar h1 {
        font-size: 1.25rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
    }
    
    .modal-content {
        padding: 1rem;
    }
    
    .toast-container {
        top: 1rem;
        right: 1rem;
        left: 1rem;
    }
    
    .toast {
        max-width: none;
    }
}

/* Dark scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a202c;
}

::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #2d3748;
}

/* Custom select styling */
select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* Loading states */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(66, 153, 225, 0.3);
    border-radius: 50%;
    border-top-color: #4299e1;
    animation: spin 1s ease-in-out infinite;
}

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

/* Sortable placeholder */
.sortable-ghost {
    opacity: 0.4;
}

.sortable-chosen {
    background: rgba(66, 153, 225, 0.1);
}

/* Focus states for accessibility */
.btn:focus,
.form-input:focus,
.sidebar-menu a:focus,
.btn-icon:focus {
    outline: 2px solid #4299e1;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .sidebar,
    .btn,
    .modal {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    body {
        background: white;
        color: black;
    }
}
