/* ===========================
   AI Card Context Manager
   Stylesheet
   =========================== */

/* ===========================
   1. Global Styles and Reset
   =========================== */

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

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

/* ===========================
   2. Layout Structure
   =========================== */

.main-wrapper {
    display: flex;
    height: 100vh;
    position: relative;
}

.container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    transition: margin-right 0.3s ease;
}

.container.sidebar-open {
    margin-right: 400px;
}

/* ===========================
   3. Header Styles
   =========================== */

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

h1 {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: -0.02em;
}

.settings-btn {
    background: #fff;
    border: 1px solid #ddd;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-left: auto;
}

.settings-btn:hover {
    background: #f8f8f8;
    border-color: #9ca3af;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ===========================
   4. Sidebar Settings Panel
   =========================== */

.settings-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background-color: #fff;
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.settings-sidebar.open {
    right: 0;
}

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

.sidebar-header h2 {
    margin: 0;
    font-size: 20px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #000;
}

.sidebar-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* ===========================
   5. Form Element Styles
   =========================== */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

.form-group input[type="checkbox"] {
    margin-right: 8px;
}

.form-group small {
    display: block;
    margin-top: 4px;
    color: #666;
    font-size: 12px;
}

/* ===========================
   6. Button Styles
   =========================== */

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.01em;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

.btn-primary:hover {
    background-color: #374151;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-secondary {
    background-color: #9ca3af;
    color: white;
    height: 40px;
    display: flex;
    align-items: center;
}

.btn-secondary:hover {
    background-color: #6b7280;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ===========================
   7. Controls and Prompt Section
   =========================== */

.top-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    align-items: flex-start;
}

/* Removed minimized cards container styles */

.prompt-section {
    display: flex;
    gap: 10px;
}

.bottom-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.container.sidebar-open .bottom-prompt {
    right: 400px;
}

.prompt-input-area {
    display: flex;
    gap: 10px;
    padding: 10px 20px;
}

#userPrompt {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    resize: none;
    height: 50px;
    font-family: inherit;
}

/* Prompt history tabs */
.prompt-history {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid #f3f4f6;
    overflow-x: auto;
    overflow-y: visible;
    white-space: nowrap;
    background: #fafbfc;
    position: relative;
}

.prompt-history:empty {
    display: none;
}

.history-tab {
    background: #e5e7eb;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #4b5563;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.history-tab:hover {
    background: #e0e0e0;
    border-color: #d0d0d0;
}

.history-tab-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-delete-btn {
    display: none;
    background: none;
    border: none;
    color: #666;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: all 0.2s;
}

.history-tab:hover .history-delete-btn {
    display: block;
}

.history-delete-btn:hover {
    color: #e53e3e;
    transform: scale(1.2);
}

/* History tooltip */
.history-tooltip {
    display: none;
    position: fixed;
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: normal;
    max-width: 300px;
    word-wrap: break-word;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    pointer-events: none;
}

.history-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
}

/* Response preview */
.response-preview {
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.response-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #fff;
}

.response-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

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

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    color: #000;
}

.response-content {
    padding: 15px 20px;
    overflow-y: auto;
    flex: 1;
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.6;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0.7;
    }
    to {
        opacity: 1;
    }
}

/* ===========================
   8. Card Container
   =========================== */

.cards-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 250px);
    overflow: auto;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 100px; /* Space for bottom prompt */
}

/* ===========================
   9. Card Styles
   =========================== */

.card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 15px;
    position: absolute;
    /* transition: box-shadow 0.2s, border-color 0.2s; */
    cursor: move;
    resize: both;
    overflow: auto;
    min-height: 150px;
    max-height: 600px;
    width: 400px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

.card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
    z-index: 10;
}

.card.dragging {
    opacity: 0.8;
    cursor: grabbing;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.card.excluded {
    opacity: 0.5;
    background: #f9f9f9;
}

/* Card header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f3f4f6;
    font-weight: 600;
    font-size: 14px;
    color: #374151;
}

.card-actions {
    display: flex;
    gap: 5px;
}

.card-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    font-size: 14px;
    transition: background 0.2s;
}

.card-btn:hover {
    background: #f0f0f0;
}

/* Card content */
.card-content {
    width: 100%;
    height: calc(100% - 80px);
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 10px;
    font-size: 14px;
    resize: none;
    min-height: 100px;
    font-family: inherit;
    background: #fafafa;
}

.card-content:focus {
    outline: none;
    border-color: #2563eb;
    background: #fff;
}

/* Resize handle */
.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 50%, #ddd 50%);
}

/* ===========================
   10. Clipped Card Styles
   =========================== */

/* Clipped cards display container */
.clipped-cards-container {
    display: none;
    gap: 10px;
    padding: 12px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f9fafb;
    flex-wrap: wrap;
}

/* Clip item */
.clip-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #e5e7eb;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}

.clip-item:hover {
    background: #d1d5db;
    border-color: #9ca3af;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.clip-name {
    color: #374151;
}

.clip-remove {
    background: none;
    border: none;
    font-size: 18px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.clip-remove:hover {
    background: #374151;
    color: white;
}

/* Card checkbox styles */
.card-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

.card-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Checkbox label hover effect */
.card-checkbox-label:hover .card-checkbox {
    outline: 2px solid #e5e7eb;
    outline-offset: 1px;
}

/* Clipped card display */
.card.clipped {
    border-color: #2563eb;
    box-shadow: 0 0 0 1px #2563eb, 0 1px 3px rgba(37, 99, 235, 0.1);
}

/* Card highlight display */
.card.highlighted {
    border-color: #fbbf24;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.3), 0 4px 12px rgba(251, 191, 36, 0.2);
    transform: translateY(-2px);
    z-index: 100;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===========================
   11. Loading Overlay
   =========================== */

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    color: white;
    margin-top: 20px;
    font-size: 16px;
}

