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

html {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-y: scroll;
    overflow-x: auto;
}

body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    overflow: visible;
}

#app {
    min-height: 100vh;
    background-color: #1a1a2e;
    background-size: 100% 100%;
    background-position: top left;
    background-repeat: no-repeat;
}

/* Toolbar */
#toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 90px 0 20px;
    z-index: 1000;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
    font-size: 1.3em;
    font-weight: bold;
    color: #e94560;
}

.page-name {
    color: #fff;
    font-size: 1em;
}

.viewing-badge {
    color: #fbbf24;
    font-size: 0.8em;
    font-weight: normal;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.btn:hover {
    background: rgba(255,255,255,0.2);
}

.btn-primary {
    background: #e94560;
    color: white;
}

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

.btn-danger {
    background: #dc3545;
}

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

/* Widget Container */
#widget-container {
    padding-top: 60px;
    min-height: 100vh;
    position: relative;
    /* Container grows to fit widgets, page scrolls if needed */
    min-width: 100%;
}

/* Widget */
.widget {
    position: absolute;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    min-width: 80px;
    min-height: 40px;
}

.widget-header {
    padding: 0 15px;
    height: var(--widget-header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
}

.widget-favicon {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    flex-shrink: 0;
    object-fit: contain;
}

.widget-title {
    font-weight: 600;
    font-size: 0.95em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    opacity: var(--text-brightness, 0.9);
}

.widget-actions {
    display: flex;
    gap: 8px;
}

.widget-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1em;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 2px;
}

.widget-btn:hover {
    opacity: 1;
}

.widget-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* RSS Feed Items */
.feed-item {
    padding: var(--feed-item-padding, 8px) 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    transition: background 0.2s;
}

.feed-item:hover {
    background: rgba(255,255,255,0.05);
}

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

.feed-item a {
    text-decoration: none;
    color: inherit;
}

.feed-item-title {
    font-weight: 500;
    font-size: 0.9em;
    margin-bottom: 4px;
    line-height: 1.3;
    opacity: var(--text-brightness, 0.9);
}

.feed-item-title a:hover {
    text-decoration: underline;
}

.feed-item-meta {
    font-size: 0.75em;
    opacity: 0.6;
}

.feed-item-description {
    font-size: 0.8em;
    opacity: 0.8;
    margin-top: 6px;
    line-height: 1.4;
}

.feed-loading, .feed-error, .feed-empty {
    padding: 20px;
    text-align: center;
    opacity: 0.7;
}

.feed-error {
    color: #ff6b6b;
}

/* Resize Handle */
/* Resize edges */
.resize-edge {
    position: absolute;
    z-index: 10;
}

.resize-edge.resize-n {
    top: 0;
    left: 10px;
    right: 10px;
    height: 6px;
    cursor: ns-resize;
}

.resize-edge.resize-s {
    bottom: 0;
    left: 10px;
    right: 10px;
    height: 6px;
    cursor: ns-resize;
}

.resize-edge.resize-e {
    top: 10px;
    right: 0;
    bottom: 10px;
    width: 6px;
    cursor: ew-resize;
}

.resize-edge.resize-w {
    top: 10px;
    left: 0;
    bottom: 10px;
    width: 6px;
    cursor: ew-resize;
}

/* Resize corners */
.resize-corner {
    position: absolute;
    width: 12px;
    height: 12px;
    z-index: 11;
}

.resize-corner.resize-nw {
    top: 0;
    left: 0;
    cursor: nwse-resize;
}

.resize-corner.resize-ne {
    top: 0;
    right: 0;
    cursor: nesw-resize;
}

.resize-corner.resize-sw {
    bottom: 0;
    left: 0;
    cursor: nesw-resize;
}

.resize-corner.resize-se {
    bottom: 0;
    right: 0;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.3) 50%);
    border-bottom-right-radius: 12px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.hidden {
    display: none !important;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #1a1a2e;
    border-radius: 12px;
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    color: #fff;
    font-size: 1.2em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    color: #fff;
    cursor: pointer;
    opacity: 0.7;
}

.modal-close:hover {
    opacity: 1;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

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

.form-group label {
    display: block;
    color: #fff;
    margin-bottom: 6px;
    font-size: 0.9em;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 0.95em;
}

.form-group input[type="text"]:focus,
.form-group input[type="url"]:focus,
.form-group input[type="password"]:focus {
    outline: none;
    border-color: #e94560;
}

.form-group input[type="color"] {
    width: 60px;
    height: 36px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
}

.slug-input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    overflow: hidden;
}

.slug-prefix {
    padding: 10px 0 10px 12px;
    color: rgba(255,255,255,0.5);
    font-size: 0.95em;
    white-space: nowrap;
}

.slug-input-wrapper input {
    flex: 1;
    border: none !important;
    background: transparent !important;
    border-radius: 0 !important;
    padding-left: 0 !important;
}

.slug-input-wrapper input:focus {
    outline: none;
}

.slug-input-wrapper:focus-within {
    border-color: #e94560;
}

.slug-status {
    font-size: 0.85em;
    margin-top: 4px;
    min-height: 1.2em;
}

.slug-status.available {
    color: #4ade80;
}

.slug-status.unavailable {
    color: #f87171;
}

.slug-status.checking {
    color: #fbbf24;
}

.form-hint {
    display: block;
    color: rgba(255,255,255,0.5);
    font-size: 0.8em;
    margin-top: 4px;
}

.danger-zone {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,100,100,0.3);
}

.danger-zone label {
    color: #f87171;
}

.danger-zone .btn-danger {
    margin-bottom: 8px;
}

/* Scrollbar */
.widget-body::-webkit-scrollbar {
    width: 6px;
}

.widget-body::-webkit-scrollbar-track {
    background: transparent;
}

.widget-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.widget-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

.widget-body.hide-scrollbars {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.widget-body.hide-scrollbars::-webkit-scrollbar {
    display: none;
}

/* Dragging state */
.widget.dragging {
    opacity: 0.8;
    z-index: 1000;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.widget.resizing {
    opacity: 0.9;
}

.widget.locked .widget-header {
    cursor: default;
}

.widget.locked .resize-edge,
.widget.locked .resize-corner {
    display: none;
}

/* Visited feed items */
.feed-item.visited {
    opacity: 0.5;
}

.feed-item.visited .feed-item-title a {
    color: #888;
}

/* Configurable sizes */
:root {
    --widget-header-height: 44px;
    --feed-item-padding: 12px;
    --text-brightness: 0.9;
}

/* Checkbox styling */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #fff;
}

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

/* Compact feed items (no preview) */
.feed-item.compact {
    /* padding controlled by --feed-item-padding variable */
}

.feed-item.compact .feed-item-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed-item.compact .feed-item-description,
.feed-item.compact .feed-item-meta {
    display: none;
}

/* Form row for side-by-side inputs */
.form-row {
    display: flex;
    gap: 15px;
}

.form-group.half {
    flex: 1;
}

.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    background: #2a2a4e;
    color: #fff;
    font-size: 0.95em;
}

.form-group select:focus {
    outline: none;
    border-color: #e94560;
}

.form-group select option {
    background: #2a2a4e;
    color: #fff;
}

.form-group input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 0.95em;
}

.form-group input[type="number"]:focus {
    outline: none;
    border-color: #e94560;
}

.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 0.95em;
    font-family: monospace;
    resize: vertical;
}

.form-group textarea:focus {
    outline: none;
    border-color: #e94560;
}

.import-export-buttons {
    display: flex;
    gap: 10px;
}

.import-export-buttons .btn {
    flex: 1;
}

/* Fullscreen modal for HTML editor */
.modal-fullscreen {
    width: 95%;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-fullscreen .modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    max-height: none;
}

.editor-body {
    padding: 0 !important;
}

.editor-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

#html-editor-content {
    flex: 1;
    width: 100%;
    height: 100%;
    padding: 20px;
    border: none;
    border-radius: 0;
    background: #0d1117;
    color: #c9d1d9;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    min-height: 0;
}

#html-editor-content:focus {
    outline: none;
}


/* TinyMCE container styles */
.editor-container .tox-tinymce {
    flex: 1;
    height: 100% !important;
    border: none !important;
    border-radius: 0 !important;
}

.editor-container .tox .tox-edit-area::before {
    border: none !important;
}

/* TinyMCE floating elements (menus, dialogs) need higher z-index than modal */
.tox-tinymce-aux {
    z-index: 3000 !important;
}

.tox.tox-silver-sink.tox-tinymce-aux .tox-dialog-wrap {
    z-index: 3000 !important;
}

/* HTML widget */
.html-content {
    padding: 15px;
    line-height: 1.5;
}

.html-content h1, .html-content h2, .html-content h3 {
    margin-bottom: 0.5em;
}

.html-content p {
    margin-bottom: 1em;
}

.html-content a {
    color: #e94560;
}

.html-content img {
    max-width: 100%;
    height: auto;
}

/* Iframe widget */
.iframe-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.iframe-container iframe {
    border: none;
    position: absolute;
}

.iframe-container.hide-scrollbars iframe {
    /* Make iframe larger than container to hide scrollbars */
    width: calc(100% + 20px);
    height: calc(100% + 20px);
}

/* Help Overlay */
.help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.help-overlay.hidden {
    display: none;
}

.help-content {
    background: #1a1a2e;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.help-header h2 {
    margin: 0;
    font-size: 1.2em;
    color: #fff;
}

.help-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5em;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.help-close:hover {
    opacity: 1;
}

.help-body {
    padding: 20px;
}

.help-section {
    margin-bottom: 20px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    font-size: 0.9em;
    color: #e94560;
    margin: 0 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.help-row {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 8px 0;
    color: #ccc;
    font-size: 0.95em;
}

.help-row kbd {
    background: #2a2a4e;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: monospace;
    font-size: 0.9em;
    min-width: 24px;
    text-align: center;
}

/* Toolbar toggle */
#toolbar.collapsed {
    transform: translateY(-100%);
}

#app.toolbar-collapsed .widget {
    transform: translateY(-25px);
}

.toolbar-show-btn {
    display: none;
}

.toolbar-toggle-fixed {
    position: fixed;
    top: 8px;
    right: 20px;
    left: auto;
    bottom: auto;
    z-index: 10000;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s;
    background: rgba(255,255,255,0.1);
    color: #fff;
    transform: none;
}

.toolbar-toggle-fixed:hover {
    background: rgba(255,255,255,0.2);
}

#toolbar {
    transition: transform 0.3s ease;
}

/* User menu styles */
.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.2);
    transition: border-color 0.2s;
}

.user-avatar:hover {
    border-color: #e94560;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 10px;
    min-width: 200px;
    z-index: 1002;
    display: none;
}

.user-dropdown.show {
    display: block;
}

.user-dropdown-info {
    padding: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 10px;
}

.user-dropdown-name {
    font-weight: bold;
    color: #fff;
}

.user-dropdown-email {
    font-size: 0.85em;
    color: rgba(255,255,255,0.6);
}

.user-dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    color: #fff;
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.user-dropdown-item:hover {
    background: rgba(255,255,255,0.1);
}

.initials-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e94560, #0f3460);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.2);
    transition: border-color 0.2s;
}

.initials-avatar:hover {
    border-color: #e94560;
}
