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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: transparent;
    color: #333;
    overflow-x: hidden;
}

/* Main Content */
#main-content {
    padding: 20px;
    margin-right: 350px;
    transition: margin-right 0.3s ease-in-out;
}

#main-content.sidebar-closed {
    margin-right: 0;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 350px;
    min-width: 250px;
    height: 100vh;
    background: linear-gradient(145deg, #2c3e50, #34495e);
    color: white;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    box-shadow: -2px 0 10px rgba(0,0,0,0.3);
    z-index: 1000;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar.resizing {
    transition: none;
    user-select: none;
}

/* Resize Handle */
.sidebar::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 4px;
    height: 100%;
    background: transparent;
    cursor: ew-resize;
    z-index: 1001;
    transition: background 0.2s ease;
}

.sidebar:hover::before,
.sidebar.resizing::before {
    background: rgba(52, 152, 219, 0.5);
}

.sidebar::after {
    content: '⋮⋮';
    position: absolute;
    left: 1px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
    font-size: 8px;
    color: rgba(255, 255, 255, 0.3);
    pointer-events: none;
    transition: color 0.2s ease;
}

.sidebar:hover::after {
    color: rgba(52, 152, 219, 0.8);
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 40px;
    background: linear-gradient(145deg, #3498db, #2980b9);
    border-radius: 6px 0 0 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease-in-out;
    box-shadow: -2px 0 5px rgba(0,0,0,0.3);
    z-index: 1001;
}

.sidebar-toggle:hover {
    background: linear-gradient(145deg, #2980b9, #3498db);
    transform: translateY(-50%) translateX(-2px);
}

.toggle-icon {
    font-size: 12px;
    color: white;
    transition: transform 0.3s ease-in-out;
}

.sidebar.open .toggle-icon {
    transform: rotate(180deg);
}

/* Sidebar Content */
.sidebar-content {
    padding: 20px;
    height: 100%;
    overflow-y: auto;
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.sidebar-content h2 {
    margin: 0;
    color: #ecf0f1;
    flex: 1;
}

.settings-btn {
    background: transparent;
    border: none;
    color: #ecf0f1;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-size: 16px;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(45deg);
}

/* Settings Panel */
.settings-panel {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.settings-panel.hidden {
    display: none;
}

.settings-panel h4 {
    margin: 0 0 15px 0;
    color: #ecf0f1;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting-group {
    margin-bottom: 12px;
}

.setting-group label {
    display: block;
    color: #bdc3c7;
    font-size: 12px;
    margin-bottom: 5px;
    font-weight: 500;
}

.setting-select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #ecf0f1;
    font-size: 12px;
}

.setting-select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
}

.setting-checkbox {
    display: flex !important;
    align-items: center;
    cursor: pointer;
    margin-bottom: 0 !important;
}

.setting-checkbox input {
    margin-right: 8px;
    transform: scale(0.9);
}

.setting-checkbox span {
    font-size: 12px;
    color: #bdc3c7;
}

/* URL Input Section */
.url-input-section {
    margin-bottom: 30px;
}

.url-input {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.9);
    color: #333;
    transition: all 0.3s ease;
}

.url-input:focus {
    outline: none;
    background: white;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

.button-group {
    display: flex;
    gap: 10px;
}

.btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(145deg, #27ae60, #2ecc71);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(145deg, #2ecc71, #27ae60);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-danger {
    background: linear-gradient(145deg, #c0392b, #e74c3c);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(145deg, #e74c3c, #c0392b);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* App List Section */
.app-list-section h3 {
    margin-bottom: 15px;
    color: #ecf0f1;
    font-size: 16px;
}

.app-list {
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

/* App Row Styles */
.app-row {
    background: rgba(255,255,255,0.1);
    margin-bottom: 10px;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    user-select: none;
}

.app-row:hover {
    background: rgba(255,255,255,0.2);
    transform: translateX(5px);
}

.app-row.selected {
    border-left-color: #3498db;
    background: rgba(52, 152, 219, 0.2);
    box-shadow: inset 0 0 0 2px rgba(52, 152, 219, 0.3);
}

.app-row.disabled {
    opacity: 0.6;
    background: rgba(231, 76, 60, 0.1);
    border-left-color: #e74c3c;
}

.app-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.app-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-right: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 11px;
    color: #bdc3c7;
    user-select: none;
}

.app-checkbox {
    margin-right: 6px;
    transform: scale(0.9);
}

.checkbox-text {
    font-weight: 500;
}

.app-title {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
    margin-right: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.app-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    font-weight: 500;
}

.app-status.inactive {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.app-url {
    font-size: 12px;
    color: #bdc3c7;
    margin-top: 4px;
    word-break: break-all;
    line-height: 1.3;
}

.app-controls {
    display: flex;
    gap: 5px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.app-row:hover .app-controls {
    opacity: 1;
}

.control-btn {
    padding: 4px 8px;
    font-size: 11px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.move-up, .move-down {
    background: rgba(52, 152, 219, 0.7);
    color: white;
}

.delete-app {
    background: rgba(231, 76, 60, 0.7);
    color: white;
}

.control-btn:hover {
    transform: scale(1.1);
}

/* Iframe Container */
#iframe-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 350px;
    bottom: 0;
    transition: right 0.3s ease-in-out;
}

#iframe-container.sidebar-closed {
    right: 0;
}

.app-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    position: absolute;
    top: 0;
    left: 0;
    visibility: visible;
    pointer-events: auto;
    z-index: 1;
}

.app-iframe.active {
    z-index: 10;
}

/* Scrollbar Styles */
.sidebar-content::-webkit-scrollbar,
.app-list::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track,
.app-list::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb,
.app-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover,
.app-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 100vw;
        transform: translateX(100vw);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    #main-content {
        margin-right: 0;
    }
    
    #iframe-container {
        right: 0;
    }
}

/* Font Size Settings */
.sidebar-content.font-small {
    font-size: 11px;
}

.sidebar-content.font-small .sidebar-header h2 {
    font-size: 16px;
}

.sidebar-content.font-small .app-title {
    font-size: 12px;
}

.sidebar-content.font-small .app-url {
    font-size: 10px;
}

.sidebar-content.font-small .checkbox-text {
    font-size: 9px;
}

.sidebar-content.font-medium {
    font-size: 14px;
}

.sidebar-content.font-large {
    font-size: 16px;
}

.sidebar-content.font-large .sidebar-header h2 {
    font-size: 20px;
}

.sidebar-content.font-large .app-title {
    font-size: 16px;
}

.sidebar-content.font-large .app-url {
    font-size: 14px;
}

.sidebar-content.font-large .checkbox-text {
    font-size: 13px;
}

/* Compact Mode */
.sidebar-content.compact-mode .app-row {
    padding: 3px 6px;
    margin-bottom: 2px;
}

.sidebar-content.compact-mode .app-row-header {
    margin-bottom: 1px;
}

.sidebar-content.compact-mode .app-title {
    margin-bottom: 1px;
    font-size: 11px;
    line-height: 1.2;
}

.sidebar-content.compact-mode .app-url {
    font-size: 9px;
    margin-top: 1px;
    line-height: 1.1;
}

.sidebar-content.compact-mode .app-controls {
    margin-top: 2px;
}

.sidebar-content.compact-mode .control-btn {
    padding: 1px 4px;
    font-size: 9px;
}

.sidebar-content.compact-mode .checkbox-text {
    font-size: 9px;
}

.sidebar-content.compact-mode .app-status {
    font-size: 9px;
    padding: 1px 4px;
}

.sidebar-content.compact-mode .url-input-section {
    margin-bottom: 12px;
}

.sidebar-content.compact-mode .settings-panel {
    padding: 8px;
    margin-bottom: 12px;
}

.sidebar-content.compact-mode .app-checkboxes {
    gap: 2px;
}

.sidebar-content.compact-mode .checkbox-label {
    font-size: 10px;
}

/* Apps Modal */
.apps-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    opacity: 1;
    visibility: visible;
}

.apps-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.apps-modal-content {
    background: #222c36;
    border-radius: 12px;
    box-shadow: 0 4px 32px rgba(0,0,0,0.7);
    padding: 24px 28px 18px 28px;
    width: 85vw;
    height: 80vh;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    resize: both;
    overflow: auto;
    min-width: 400px;
    min-height: 300px;
}

.apps-modal-textarea {
    width: 100%;
    flex-grow: 1;
    resize: none;
    border-radius: 8px;
    border: 2px solid #fff;
    background: rgba(0,0,0,0.85);
    color: #fff;
    font-size: 15px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin-bottom: 10px;
    padding: 10px;
    outline: none;
}

.apps-modal-hint {
    color: #fff;
    opacity: 0.7;
    font-style: italic;
    font-size: 13px;
    margin-bottom: 10px;
}

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