/* Container Library UI Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

#app {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 15px;
}

header h1 {
    color: #2c3e50;
    font-size: 2rem;
    font-weight: 300;
    margin: 0;
}

/* Header Controls Container */
.header-controls {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 8px;
}

/* Edit Mode Toggle */
.edit-mode-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.edit-mode-toggle:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.edit-mode-toggle.active {
    background-color: #007bff;
    color: white;
}

.edit-mode-toggle.active:hover {
    background-color: #0056b3;
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    gap: 12px;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Toolbar Buttons */
.toolbar-btn {
    background: #0056b3; /* Darker blue for better contrast (meets WCAG AA) */
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.toolbar-btn:hover {
    background: #004085; /* Even darker on hover */
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 64, 133, 0.3);
}

.toolbar-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0, 64, 133, 0.3);
}

.toolbar-btn:focus {
    outline: 2px solid #0056b3;
    outline-offset: 2px;
}

/* Danger button variant (for Clear All) */
.toolbar-btn-danger {
    background: #8b2332; /* Darker red for better contrast (meets WCAG AAA 7:1) */
}

.toolbar-btn-danger:hover {
    background: #721d28; /* Even darker on hover */
    box-shadow: 0 2px 6px rgba(139, 35, 50, 0.3);
}

.toolbar-btn-danger:focus {
    outline: 2px solid #8b2332;
    outline-offset: 2px;
}

/* Last Saved Timestamp */
.last-saved {
    font-size: 13px;
    color: #6c757d;
    font-style: italic;
    white-space: nowrap;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #343a40;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 400px;
    word-wrap: break-word;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: #28a745;
}

.toast-error {
    background: #dc3545;
}

.toast-info {
    background: #17a2b8;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.5rem;
    }

    .toolbar {
        padding: 10px 12px;
    }

    .toolbar-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    .last-saved {
        font-size: 12px;
    }

    .toast {
        right: 10px;
        left: 10px;
        bottom: 10px;
        max-width: none;
    }
}

.container-display {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Container Item Styles */
.container-item {
    margin: 4px 0;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.container-item:hover {
    background-color: #f8f9fa;
}

.container-content {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
}

.container-content:hover {
    background-color: #e9ecef;
}

/* Expansion Toggle */
.expansion-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    cursor: pointer;
    font-size: 12px;
    color: #6c757d;
    user-select: none;
}

.expansion-toggle:hover {
    color: #495057;
}

.expansion-toggle.hidden {
    visibility: hidden;
}

/* Container Title */
.container-title {
    flex: 1;
    padding: 4px 8px;
    font-size: 14px;
    color: #343a40;
    text-decoration: none;
    border-radius: 3px;
    transition: color 0.2s ease;
}

.container-title.has-link {
    color: #003d7a;
    cursor: pointer;
}

.container-title.has-link:hover {
    color: #0052a3;
    text-decoration: underline;
}

.container-title.no-link {
    color: #343a40;
    cursor: default;
}

/* Subcontainer Indentation */
.subcontainers {
    margin-left: 20px;
    border-left: 1px solid #e9ecef;
    padding-left: 12px;
}

.subcontainers.collapsed {
    display: none;
}

/* Visual States */
.container-item.expanded > .container-content .expansion-toggle {
    transform: rotate(90deg);
}

.container-item.leaf .expansion-toggle {
    opacity: 0.3;
}

/* Container Depth Indicators */
.container-item[data-depth="0"] {
    font-weight: 500;
}

.container-item[data-depth="1"] .container-title {
    font-size: 13px;
}

.container-item[data-depth="2"] .container-title {
    font-size: 12px;
    color: #6c757d;
}

.container-item[data-depth="3"] .container-title,
.container-item[data-depth="4"] .container-title,
.container-item[data-depth="5"] .container-title {
    font-size: 11px;
    color: #adb5bd;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-style: italic;
}

/* Debug Information */
.debug-info {
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    color: #495057;
    border-left: 3px solid #007bff;
}

.debug-info h2 {
    margin-bottom: 8px;
    color: #343a40;
    font-family: inherit;
    font-size: 14px;
}

/* Drag and Drop Styles */
.container-item.draggable {
    cursor: grab;
    user-select: none;
    transition: all 0.2s ease;
}

.container-item.draggable:hover {
    background-color: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.container-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
    transform: rotate(2deg);
    z-index: 1000;
}

.container-item.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1001;
    opacity: 0.8;
    background: white;
    border: 2px dashed #007bff;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: rotate(2deg);
}

.drop-zone {
    min-height: 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
    margin: 6px 0;
    opacity: 0.3;
    background-color: #e9ecef;
}

.drop-zone.active {
    background-color: #007bff;
    min-height: 20px;
    margin: 8px 0;
    box-shadow: 0 0 12px rgba(0, 123, 255, 0.4);
    opacity: 1;
    border: 2px solid #0056b3;
}

.drop-zone.invalid {
    background-color: #dc3545;
    min-height: 16px;
    margin: 6px 0;
    opacity: 1;
    border: 2px solid #c82333;
    animation: pulse-red 0.5s ease-in-out;
}

@keyframes pulse-red {
    0% { background-color: #dc3545; }
    50% { background-color: #ff6b6b; }
    100% { background-color: #dc3545; }
}

.subcontainers.drag-over {
    background-color: rgba(0, 123, 255, 0.05);
    border: 2px dashed #007bff;
    border-radius: 4px;
    padding: 4px;
}

/* Drag Handle */
.drag-handle {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    cursor: grab;
    opacity: 0.3;
    transition: opacity 0.2s ease;
    font-size: 12px;
    line-height: 16px;
    text-align: center;
}

.container-item:hover .drag-handle {
    opacity: 0.6;
}

.drag-handle:hover {
    opacity: 1;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Favicon */
.favicon {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    vertical-align: top;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.favicon.loaded {
    opacity: 1;
}

.favicon.error {
    display: none;
}

/* Favicon placeholder to prevent layout shift */
.favicon-placeholder {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    vertical-align: top;
}

/* Drag handle spacing - matches drag handle dimensions */
.drag-handle-spacing {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    vertical-align: top;
}

/* Hover-to-expand styles */
.container-item.hover-target {
    background-color: rgba(0, 123, 255, 0.1);
    border: 2px dashed #007bff;
    border-radius: 6px;
    transform: scale(1.02);
    transition: all 0.3s ease;
}

.container-item.hover-target.expand-ready {
    background-color: rgba(0, 123, 255, 0.2);
    border-color: #0056b3;
    box-shadow: 0 0 16px rgba(0, 123, 255, 0.3);
}

.container-item.drop-ready {
    background-color: rgba(0, 255, 0, 0.1);
    border: 1px solid #28a745;
    border-radius: 4px;
    /* No layout changes - just visual indication */
}

.hover-timer-indicator {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #007bff;
    color: white;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1002;
    animation: countdown 2s linear forwards;
}

@keyframes countdown {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}