/* Google Fonts are imported in index.html now */

:root {
    /* Global Reset */
    box-sizing: border-box;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

:root {
    /* Brand Colors */
    --primary: #3b82f6;
    /* Vibrant Blue */
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --accent: #8b5cf6;
    /* Violet accent */

    /* Functional Colors */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    /* Neutral / Surface */
    --bg-body: #f8fafc;
    /* Slate 50 */
    --bg-card: #ffffff;
    --text-main: #0f172a;
    /* Slate 900 */
    --text-muted: #64748b;
    /* Slate 500 */
    --border-subtle: #e2e8f0;
    /* Slate 200 */

    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Spacing & Layout */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-card-hover: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    --transition-base: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: var(--font-body);
    color: var(--text-main);
    background-color: var(--bg-body);
    margin: 0;
    padding: 24px;
    font-size: 14px;
    /* Trello standard base */
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Headings */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--text-main);
    margin: 0;
    line-height: 1.2;
}

h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
    letter-spacing: -0.02em;
}

h3 {
    font-size: 18px;
    font-weight: 600;
}

/* Layout Containers */
#app {
    max-width: 900px;
    margin: 0 auto;
}

/* Header Sections */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.view-header h2 {
    margin-bottom: 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Buttons */
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-base);
    gap: 8px;
}

button.primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

button.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(59, 130, 246, 0.4);
}

button.secondary {
    background: white;
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
}

button.secondary:hover {
    border-color: var(--primary-light);
    color: var(--primary);
    background: #f8fafc;
}

button.danger {
    background: transparent;
    color: var(--text-muted);
}

button.danger:hover {
    color: var(--danger);
    background: #fef2f2;
}

button.success {
    background-color: #ecfdf5;
    color: var(--success);
}

button.success:hover {
    background-color: #d1fae5;
}

/* Lists */
.template-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Card Component */
.template-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition-base);
}

.template-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
}

.template-info h3 {
    margin-bottom: 6px;
    color: var(--text-main);
}

.template-info p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.action-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    color: var(--text-muted);
    background: transparent;
}

.btn-icon:hover {
    background: var(--bg-body);
    color: var(--text-main);
}

/* Form Styles (Builder/Instantiate) */
input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background-color: #fff;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 14px;
    transition: var(--transition-base);
    box-sizing: border-box;
    margin-bottom: 16px;
}

/* Enforce consistent height for single-line inputs */
input[type="text"],
input[type="number"],
select:not([multiple]) {
    height: 40px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-main);
    font-size: 13px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px;
    background: white;
    border-radius: var(--radius-md);
    border: 2px dashed var(--border-subtle);
    color: var(--text-muted);
}

/* Instantiation Form Specifics */
.page-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding-top: 40px;
    padding-bottom: 40px;
}

.instantiate-card {
    width: 60%;
    max-width: 800px;
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-subtle);
}

.btn-back {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
    transition: color 0.2s;
}

.btn-back:hover {
    color: var(--primary);
}

.form-section {
    margin-bottom: 32px;
}

.form-section h3 {
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.form-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.attributes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.attribute-input-wrapper {
    margin-bottom: 0;
    /* Grid handles spacing */
}

/* Checkbox styling */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: white;
    transition: var(--transition-base);
}

.checkbox-wrapper:hover {
    border-color: var(--primary-light);
    background: #f8fafc;
}

.checkbox-wrapper input[type="checkbox"] {
    margin: 0;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* Select styling */
select[multiple] {
    height: auto;
    min-height: 120px;
    padding: 8px;
    background-image: none;
    /* Remove arrow */
    overflow-y: auto;
}

select[multiple] option {
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 2px;
}

select[multiple] option:checked {
    background-color: var(--primary-light);
    /* Or a lighter version */
    color: white;
    /* Depends on contrast, let's use primary color bg */
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.helper-text {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Error / Info States */
.state-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    text-align: center;
}

.state-card {
    background: var(--bg-card);
    padding: 48px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 480px;
    width: 100%;
    border: 1px solid var(--border-subtle);
}

.state-icon {
    font-size: 48px;
    margin-bottom: 24px;
    display: block;
}

.form-actions {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Smartlist Mirror View */
.mirror-container {
    font-family: var(--font-body);
    color: var(--text-main);
    padding: 8px 4px;
    /* Tight padding for card back */
}

.mirror-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.mirror-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--text-main);
}

.status-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 99px;
    /* Pill shape */
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-tag.active {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-tag.completed {
    background-color: #d1fae5;
    color: #065f46;
}

.progress-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.progress-track {
    flex-grow: 1;
    height: 8px;
    background-color: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 4px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    min-width: 40px;
    text-align: right;
}

.mirror-task-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: white;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    transition: var(--transition-base);
}

/* States */
.task-item.doable {
    border-left: 3px solid var(--primary);
    box-shadow: var(--shadow-sm);
}

.task-item.pending {
    background: #f8fafc;
    color: var(--text-muted);
    border-left: 3px solid transparent;
    /* Alignment */
}

.task-item.completed {
    background: #f8fafc;
    color: var(--text-muted);
    text-decoration: line-through;
    opacity: 0.8;
}

.task-item.skipped {
    background: #f1f5f9;
    color: #94a3b8;
    text-decoration: line-through;
}

.task-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.task-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.task-name {
    font-size: 14px;
    font-weight: 500;
}

.team-badge {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    background: #f1f5f9;
    color: #475569;
    white-space: nowrap;
}

/* Dynamic Team Badge Colors */
.badge-blue {
    background: #dbeafe;
    color: #1e40af;
}

.badge-green {
    background: #d1fae5;
    color: #065f46;
}

.badge-yellow {
    background: #fef3c7;
    color: #92400e;
}

.badge-purple {
    background: #ede9fe;
    color: #5b21b6;
}

.badge-pink {
    background: #fce7f3;
    color: #9d174d;
}

.task-meta {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Smartlist Template Builder */
.builder-container {
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: 60px;
}

.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.form-card h3 {
    margin-bottom: 8px;
    font-size: 16px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 12px;
}

.help-text {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
    display: block;
}

.dynamic-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.dynamic-item {
    background: #f8fafc;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 16px;
    position: relative;
    transition: var(--transition-base);
}

/* FIX: Override generic .task-item flex style from mirror view */
.builder-container .task-item {
    display: block;
}

.dynamic-item:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.input-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    /* Ensure top alignment */
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
}

.input-col {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.input-col label {
    font-size: 12px;
    margin-bottom: 4px;
    font-weight: 600;
}

.input-col input,
.input-col select,
.input-col textarea {
    margin-bottom: 0;
    /* Override default */
}

.input-sm {
    max-width: 120px;
}

.input-md {
    max-width: 200px;
}

.btn-remove-item {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    border: 1px solid var(--border-subtle);
    color: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-base);
}

.btn-remove-item:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* Drag and Drop Styles */
.task-item {
    transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.2s;
}

.task-item.dragging {
    opacity: 0.5;
    background: #e2e8f0;
    border: 1px dashed #94a3b8;
}

.drag-handle {
    cursor: grab;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    margin-right: 8px;
}

.drag-handle:active {
    cursor: grabbing;
    color: var(--primary);
}

.task-header {
    display: flex;
    align-items: flex-end;
    /* Align with inputs */
    width: 100%;
}

.builder-actions {
    position: sticky;
    bottom: 20px;
    background: white;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.btn-add-dashed {
    width: 100%;
    border: 1px dashed var(--border-subtle);
    background: transparent;
    color: var(--primary);
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-base);
    font-weight: 500;
}


.btn-add-dashed:hover {
    background: #eff6ff;
    border-color: var(--primary);
}

/* Custom Multi-Select Dropdown */
.multi-select-container {
    position: relative;
    width: 100%;
    margin-bottom: 0;
}

.multi-select-trigger {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    /* Match standard input padding */
    background: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 36px;
    /* Match standard input height */
    min-height: 36px;
    font-size: 13px;
    /* Match font size */
    user-select: none;
}

.multi-select-trigger:hover {
    border-color: var(--primary-light);
}

.multi-select-trigger.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.multi-select-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.multi-select-menu.open {
    display: block;
}

.multi-select-option {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 13px;
}

.multi-select-option:hover {
    background: #f1f5f9;
}

.multi-select-option input[type="checkbox"] {
    margin: 0;
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
}

.multi-select-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Builder Density Adjustments */
.builder-container .dynamic-item {
    padding: 12px;
    /* Reduced from 16px */
    margin-bottom: 12px;
    /* Reduced margin */
}

/* Reduce input margins inside builder items */
.builder-container .input-col label {
    margin-bottom: 2px;
    font-size: 11px;
    /* Slightly smaller label */
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted);
}

.builder-container input[type="text"],
.builder-container input[type="number"],
.builder-container select {
    height: 36px;
    /* Slightly compact */
    padding: 6px 10px;
    font-size: 13px;
    margin-bottom: 0;
    /* Let flex gap handle spacing or specific margins */
}

/* Task Description Button */
.btn-task-desc {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-task-desc:hover {
    background: var(--bg-body);
    border-color: var(--primary-light);
    color: var(--primary);
}

.btn-task-desc.has-description {
    background: #eff6ff;
    border-color: var(--primary);
    color: var(--primary);
}

/* Task Description Modal */
.task-desc-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-desc-modal .modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}

.task-desc-modal .modal-content {
    position: relative;
    background: white;
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    z-index: 1;
}

.task-desc-modal .modal-content h4 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
}

.task-desc-modal .task-desc-textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    margin-bottom: 16px;
}

.task-desc-modal .task-desc-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.task-desc-modal .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Task Checklist Button (same style as description button) */
.btn-task-checklist {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-task-checklist:hover {
    background: var(--bg-body);
    border-color: var(--primary-light);
    color: var(--primary);
}

.btn-task-checklist.has-checklist {
    background: #d1fae5;
    border-color: #10b981;
    color: #059669;
}