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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #000000;
    color: #ffffff;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: grid;
    grid-template-areas: 
        "header header"
        "sidebar main";
    grid-template-rows: auto 1fr;
    grid-template-columns: 250px 1fr;
    height: 100vh;
}

.header {
    grid-area: header;
    background: #000000;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333333;
}

.header-title-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.header h1 {
    color: #ffffff;
    font-size: 1.8rem;
    font-weight: 600;
    margin: 0;
}

.header-workspace-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: #aaaaaa;
}

.controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.header .controls .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

.add-stream-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-settings {
    background: #333333;
    border-color: #555555;
}

.btn-settings:hover {
    background: #444444;
}

.settings-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.popup-section-label {
    color: #aaaaaa;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stream-input {
    padding: 0.75rem 1rem;
    border: 1px solid #333333;
    border-radius: 4px;
    background: #000000;
    color: #ffffff;
    font-size: 0.9rem;
    min-width: 200px;
}

.stream-input:focus {
    outline: none;
    border-color: #666666;
}

.stream-input::placeholder {
    color: #666666;
}

.btn {
    background: #333333;
    color: white;
    border: 1px solid #555555;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}

.btn:hover {
    background: #444444;
}

.btn:active {
    background: #222222;
}

.btn-add {
    background: #333333;
    border-color: #555555;
}

.btn-add:hover {
    background: #444444;
}

.btn-save {
    background: #333333;
    border-color: #555555;
}

.btn-save:hover {
    background: #444444;
}

.btn-load {
    background: #333333;
    border-color: #555555;
}

.btn-load:hover {
    background: #444444;
}

.btn-clear {
    background: #cc0000;
    border-color: #ff0000;
}

.btn-clear:hover {
    background: #ff0000;
}

.btn-bulk {
    background: #333333;
    border-color: #555555;
}

.btn-bulk:hover {
    background: #444444;
}

.btn-folder {
    background: #333333;
    border-color: #555555;
}

.btn-folder:hover {
    background: #444444;
}

.btn-workspace-header {
    background: #333333;
    border-color: #555555;
}

.btn-workspace-header:hover {
    background: #444444;
}

.header-search {
    flex-shrink: 0;
}

.header-search-input {
    background: #222222;
    color: #ffffff;
    border: 1px solid #555555;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    min-width: 160px;
    max-width: 220px;
}

.header-search-input::placeholder {
    color: #888888;
}

.header-search-input:focus {
    outline: none;
    border-color: #9146ff;
}

.view-toggle {
    display: flex;
    gap: 0;
}

.btn-view {
    background: #333333;
    border-color: #555555;
    border-radius: 0;
    padding: 0.5rem 0.75rem;
}

.btn-view:first-child {
    border-radius: 4px 0 0 4px;
}

.btn-view:last-child {
    border-radius: 0 4px 4px 0;
}

.btn-view-active {
    background: #9146ff;
    border-color: #9146ff;
}

.btn-view:hover:not(.btn-view-active) {
    background: #444444;
}

.folder-button {
    background: #333333;
    color: white;
    border: 1px solid #555555;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: 0.5rem;
}

.folder-button:hover {
    background: #444444;
}

.folder-name {
    background: #6c0081;
    color: white;
    border: 1px solid #d18bff;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    display: inline-block;
}


.folder-name:hover {
    background: #8c00ff;
}

.folder-section {
    margin-bottom: 0.2rem;
}

.folder-header {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.4rem 0.5rem;
    background: #222222;
    border-radius: 4px;
    margin-bottom: 0.25rem;
}

.folder-title-row {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin: -0.15rem 0;
}

.folder-title-row:hover {
    color: #cccccc;
}

.folder-title {
    flex: 1;
    min-width: 0;
}

.folder-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: #ffffff;
    background: #555555;
    border-radius: 4px;
    flex-shrink: 0;
}

.folder-header-actions {
    display: flex;
    gap: 0.25rem;
}

.folder-action-btn {
    background: #333333;
    color: white;
    border: 1px solid #555555;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
}

.folder-action-btn:hover {
    background: #444444;
}

.folder-action-btn.hide-all-btn:hover {
    background: #552222;
    border-color: #663333;
}

.folder-action-btn.show-all-btn:hover {
    background: #224422;
    border-color: #335533;
}

.folder-action-btn.rename-folder-btn {
    padding: 0.25rem;
    line-height: 0;
}

.folder-action-btn.rename-folder-btn:hover {
    background: #444466;
    border-color: #555577;
}

.folder-icon-pencil {
    display: block;
    vertical-align: middle;
}

.folder-action-btn.delete-folder-btn:hover {
    background: #552222;
    border-color: #663333;
}

.folder-content {
    margin-left: 1rem;
    display: none;
}

.folder-content.expanded {
    display: block;
}

.hidden-stream-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    background: #111111;
    border-radius: 4px;
    margin-bottom: 0.25rem;
}

/* Popup Styles */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-overlay-on-top {
    z-index: 1100;
}

.popup-content {
    background: #111111;
    border: 1px solid #333333;
    border-radius: 8px;
    min-width: 400px;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.popup-content-wide {
    min-width: 450px;
    max-width: 560px;
}

.workspace-management-create {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.25rem;
}

.workspace-management-create .popup-input,
.workspace-management-input {
    flex: 1;
    min-width: 0;
    width: 0; /* allow flex shrink */
    margin-bottom: 0;
}

.workspace-management-create .btn {
    flex-shrink: 0;
}

.workspace-management-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 280px;
    overflow-y: auto;
}

.workspace-management-list::-webkit-scrollbar {
    width: 8px;
}

.workspace-management-list::-webkit-scrollbar-track {
    background: #111111;
    border-radius: 4px;
}

.workspace-management-list::-webkit-scrollbar-thumb {
    background: #333333;
    border-radius: 4px;
}

.workspace-management-list::-webkit-scrollbar-thumb:hover {
    background: #555555;
}

.workspace-management-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #222222;
    border: 1px solid #333333;
    border-radius: 4px;
}

.workspace-management-name {
    font-size: 0.95rem;
    color: #ffffff;
    min-width: 0;
}

.workspace-management-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

.popup-textarea {
    width: 100%;
    min-height: 180px;
    background: #222222;
    color: #ffffff;
    border: 1px solid #444444;
    padding: 0.75rem;
    border-radius: 4px;
    font-size: 1rem;
    margin-bottom: 0.75rem;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
}

.popup-textarea:focus {
    outline: none;
    border-color: #666666;
}

.popup-textarea::placeholder {
    color: #888888;
}

.bulk-import-folder-row {
    margin-bottom: 1rem;
}

.bulk-import-folder-row .popup-label {
    margin-bottom: 0.5rem;
}

.bulk-import-folder-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.bulk-import-folder-controls .folder-select {
    flex: 1;
    min-width: 160px;
    margin-bottom: 0;
    padding: 0.5rem 0.75rem;
    height: 2.25rem;
    min-height: 2.25rem;
    line-height: 1.25;
    box-sizing: border-box;
}

.bulk-import-new-folder-inline {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.75rem;
}

.bulk-import-new-folder-inline .bulk-import-inline-input {
    flex: 1;
    margin-bottom: 0;
}

.bulk-import-hint {
    color: #888888;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

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

.popup-header h3 {
    margin: 0;
    color: #ffffff;
    font-size: 1.2rem;
}

.popup-close {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.popup-close:hover {
    background: #333333;
}

.popup-body {
    padding: 1.5rem;
}

.folder-select {
    width: 100%;
    background: #222222;
    color: #ffffff;
    border: 1px solid #444444;
    padding: 0.75rem;
    border-radius: 4px;
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

.folder-select:focus {
    outline: none;
    border-color: #666666;
}

.delete-workspace-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
    cursor: pointer;
    color: #cccccc;
    font-size: 0.95rem;
}

.delete-workspace-option:hover {
    color: #ffffff;
}

.delete-workspace-checkbox {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: #9146ff;
    cursor: pointer;
}

.popup-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.btn-primary {
    background: #8B4513;
    border-color: #A0522D;
}

.btn-primary:hover {
    background: #A0522D;
}

.btn-secondary {
    background: #333333;
    border-color: #555555;
}

.btn-secondary:hover {
    background: #444444;
}

.btn-cancel {
    background: #666666;
    border-color: #888888;
}

.btn-cancel:hover {
    background: #777777;
}

.btn-danger {
    background: #cc0000;
    border-color: #ff0000;
}

.btn-danger:hover {
    background: #ff0000;
}

#removeMessage {
    color: #ffffff;
    margin-bottom: 1.5rem;
    font-size: 1rem;
    line-height: 1.5;
}

.popup-label {
    display: block;
    color: #ffffff;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.popup-input {
    width: 100%;
    background: #222222;
    color: #ffffff;
    border: 1px solid #444444;
    padding: 0.75rem;
    border-radius: 4px;
    font-size: 1rem;
    margin-bottom: 1.5rem;
    box-sizing: border-box;
}

.popup-input:focus {
    outline: none;
    border-color: #666666;
}

.popup-input::placeholder {
    color: #888888;
}

#clearMessage {
    color: #ffffff;
    margin-bottom: 1.5rem;
    font-size: 1rem;
    line-height: 1.5;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.btn-remove {
    background: #333333;
    border-color: #555555;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
}

.btn-remove:hover {
    background: #444444;
}

.sidebar {
    grid-area: sidebar;
    background: #000000;
    padding: 1rem;
    border-right: 1px solid #333333;
    overflow-y: auto;
    max-height: calc(100vh - 80px);
}

/* Custom Scrollbar Styling for Sidebar */
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: #111111;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #333333;
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #555555;
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section h3 {
    color: #ffffff;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.workspace-section {
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #333333;
    margin-bottom: 1rem;
}

.workspace-controls {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.workspace-select {
    flex: 1;
    min-width: 0;
    background: #222222;
    color: #ffffff;
    border: 1px solid #555555;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
}

.workspace-select:focus {
    outline: none;
    border-color: #666666;
}

.btn-workspace {
    flex-shrink: 0;
    padding: 0.4rem 0.6rem;
    font-size: 1rem;
    line-height: 1;
}

.btn-danger-secondary {
    background: transparent;
    border-color: #cc4444;
    color: #cc4444;
}

.btn-danger-secondary:hover {
    background: #332222;
    color: #ff6666;
}

.workspace-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.workspace-block {
    margin-bottom: 1rem;
}

.workspace-block-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: #aaaaaa;
    margin-bottom: 0.4rem;
    padding-left: 0.25rem;
}

.workspace-block-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.hidden-streams-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.hidden-stream-item {
    background: #111111;
    padding: 0.75rem;
    border-radius: 4px;
    border: 1px solid #333333;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hidden-stream-item:hover {
    background: #222222;
}

.hidden-stream-name {
    font-size: 0.9rem;
    color: #ffffff;
}

.show-stream-btn {
    background: #333333;
    color: white;
    border: 1px solid #555555;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}

.show-stream-btn:hover {
    background: #444444;
}

.no-hidden {
    color: #666666;
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

.main-content {
    grid-area: main;
    padding: 0;
    overflow: hidden;
    background: #000000;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.streams-container {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.streams-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1rem;
    padding-bottom: 2rem;
    overflow-y: auto;
    align-content: start;
    height: calc(100vh - 120px);
    min-height: 0;
    grid-auto-rows: min-content;
}

/* Custom Scrollbar Styling */
.streams-grid::-webkit-scrollbar {
    width: 8px;
}

.streams-grid::-webkit-scrollbar-track {
    background: #111111;
    border-radius: 4px;
}

.streams-grid::-webkit-scrollbar-thumb {
    background: #333333;
    border-radius: 4px;
}

.streams-grid::-webkit-scrollbar-thumb:hover {
    background: #555555;
}

.streams-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem;
    overflow-y: auto;
    height: 100%;
    min-height: 0;
}

.streams-list::-webkit-scrollbar {
    width: 8px;
}

.streams-list::-webkit-scrollbar-track {
    background: #111111;
    border-radius: 4px;
}

.streams-list::-webkit-scrollbar-thumb {
    background: #333333;
    border-radius: 4px;
}

.streams-list::-webkit-scrollbar-thumb:hover {
    background: #555555;
}

.stream-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 1rem;
    background: #111111;
    border: 1px solid #333333;
    border-radius: 4px;
}

.stream-list-item:hover {
    border-color: #9146ff;
}

.stream-list-name {
    font-weight: 500;
    color: #ffffff;
}

.stream-list-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.stream-list-folder {
    background: #6c0081;
    color: white;
    border: 1px solid #d18bff;
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}

.stream-list-folder:hover {
    background: #8c00ff;
}

.stream-item {
    background: #111111;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #333333;
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: fit-content;
    min-height: 300px;
}

.stream-item:hover {
    border-color: #9146ff;
}


.stream-item.hidden {
    display: none;
}

.stream-iframe {
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 Aspect Ratio (9/16 = 0.5625) */
    position: relative;
    border: none;
    background: #000;
    flex-shrink: 0;
    min-height: 200px;
    overflow: hidden;
}

.stream-iframe iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    min-height: 200px;
    background: #000;
}

.stream-info {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.stream-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.stream-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
}


.hide-stream-btn {
    background: #333333;
    color: white;
    border: 1px solid #555555;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.hide-stream-btn:hover {
    background: #444444;
}

.stream-info-btn {
    background: #333333;
    color: white;
    border: 1px solid #555555;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.stream-info-btn:hover {
    background: #444444;
}

.stream-clips-btn {
    background: #333333;
    color: white;
    border: 1px solid #555555;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.stream-clips-btn:hover {
    background: #444444;
}

.open-twitch-btn {
    background: #333333;
    color: white;
    border: 1px solid #555555;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.open-twitch-btn:hover {
    background: #444444;
}

.remove-stream-btn {
    background: #333333;
    color: white;
    border: 1px solid #555555;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.remove-stream-btn:hover {
    background: #444444;
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    font-size: 1.2rem;
    color: #ffffff;
}

.error {
    color: #ffffff;
    text-align: center;
    padding: 2rem;
    font-size: 1.1rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .streams-grid {
        grid-template-columns: repeat(2, 1fr);
        height: calc(100vh - 100px);
        grid-auto-rows: min-content;
    }
    
    .stream-item {
        min-height: 350px;
    }
}

@media (max-width: 768px) {
    .container {
        grid-template-areas: 
            "header"
            "main";
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .sidebar {
        display: none;
    }
    
    .streams-grid {
        grid-template-columns: 1fr;
        height: calc(100vh - 80px);
        padding: 0.5rem;
        grid-auto-rows: min-content;
    }
    
    .stream-item {
        min-height: 400px;
    }
    
    .header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .controls {
        width: 100%;
        justify-content: center;
    }
    
    .main-content {
        padding: 0;
    }
}

@media (max-width: 480px) {
    .streams-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        height: calc(100vh - 60px);
        padding: 0.25rem;
        grid-auto-rows: min-content;
    }
    
    .main-content {
        padding: 0;
    }
    
    .stream-item {
        height: fit-content;
        width: 100%;
        min-height: 300px;
    }
}
