/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Allow page to scroll naturally instead of fixed viewport */
}

/* Header */
.header {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-md) var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.header-actions {
    display: flex;
    gap: var(--spacing-md);
}

/* Buttons */
.btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
}

.btn-icon {
    padding: var(--spacing-xs);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.icon {
    font-size: 18px;
}

/* Selection Toolbar */
.selection-toolbar {
    max-width: 1400px;
    margin: var(--spacing-md) auto;
    padding: var(--spacing-md) var(--spacing-lg);
    background-color: var(--primary-color);
    color: white;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
}

.selection-toolbar.hidden {
    display: none;
}

.selection-info {
    font-weight: 600;
    font-size: 14px;
}

.selection-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.selection-toolbar .btn {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.selection-toolbar .btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Toolbar */
.toolbar {
    max-width: 1400px;
    margin: var(--spacing-lg) auto;
    padding: 0 var(--spacing-lg);
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    align-items: center;
}

.search-container {
    flex: 1;
    min-width: 200px;
}

.search-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: all var(--transition-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filters {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.filter-select {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    background-color: var(--bg-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Board Container */
.board-container {
    flex: 1;
    overflow-x: auto;
    overflow-y: visible;
    padding: 0 var(--spacing-lg) var(--spacing-xl);
    /* Remove min-height to allow natural flow */
}

.board {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: var(--spacing-lg);
    align-items: flex-start;
    /* Remove min-height - let it grow naturally with content */
}

/* Column */
.column {
    flex: 1;
    min-width: 280px;
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    /* Remove max-height to allow free flow */
    min-height: 200px;
}

.column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--border-color);
    gap: var(--spacing-sm);
}

.column-add-btn {
    padding: var(--spacing-xs) var(--spacing-sm);
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.column-add-btn:hover {
    background-color: var(--primary-hover);
    transform: scale(1.1);
    box-shadow: var(--shadow-sm);
}

.btn-icon-small {
    padding: 0;
    min-width: auto;
}

.column-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.column-count {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.column-tasks {
    flex: 1;
    overflow-y: visible;
    padding: var(--spacing-xs);
    min-height: 100px;
    /* Remove max-height to allow free flow - tasks will expand naturally */
}

.column-tasks.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-size: 14px;
    padding: var(--spacing-xl);
}

/* Column Color Themes */
.column[data-column="todo"] {
    border-top: 4px solid #3b82f6;
}

.column[data-column="inprogress"] {
    border-top: 4px solid #f59e0b;
}

.column[data-column="done"] {
    border-top: 4px solid #10b981;
}

/* Task Card */
.task-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    cursor: move;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    position: relative;
}

.task-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--border-hover);
}

.task-card.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.task-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-sm);
    gap: var(--spacing-sm);
}

.task-checkbox {
    margin-right: var(--spacing-xs);
    cursor: pointer;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.task-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    flex: 1;
    word-break: break-word;
}

.task-actions {
    display: flex;
    gap: var(--spacing-xs);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.task-card:hover .task-actions {
    opacity: 1;
}

.task-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.task-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-sm);
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--bg-tertiary);
}

.task-meta {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    flex-wrap: wrap;
}

.priority-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.priority-critical {
    background-color: #fee2e2;
    color: var(--priority-critical);
}

.priority-high {
    background-color: #fed7aa;
    color: var(--priority-high);
}

.priority-medium {
    background-color: #fef3c7;
    color: #ca8a04;
}

.priority-low {
    background-color: #f3f4f6;
    color: var(--priority-low);
}

.task-tags {
    display: flex;
    gap: var(--spacing-xs);
    flex-wrap: wrap;
}

.tag {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
}

.task-due-date {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.task-due-date.overdue {
    color: var(--danger-color);
    font-weight: 600;
}

/* Drag and Drop States */
.column.drag-over {
    background-color: var(--bg-tertiary);
    border-color: var(--primary-color);
    border-style: dashed;
}

.drop-indicator {
    height: 2px;
    background-color: var(--primary-color);
    margin: var(--spacing-sm) 0;
    border-radius: 2px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.drop-indicator.active {
    opacity: 1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-modal);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    animation: fadeIn var(--transition-normal);
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp var(--transition-normal);
}

.modal-small {
    max-width: 450px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--spacing-md) var(--spacing-lg);
}

.modal-body p {
    margin-bottom: var(--spacing-sm);
    font-size: 13px;
}

/* Form Styles */
.task-form {
    padding: var(--spacing-md) var(--spacing-lg);
}

.form-group {
    margin-bottom: var(--spacing-sm);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
}

.deadline-group {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    background-color: var(--bg-secondary);
}

.deadline-inputs {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-xs);
}

.form-group-inline {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.inline-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 100px;
    margin-bottom: 0 !important;
}

.form-group-inline .form-input {
    flex: 1;
}

/* Make weeks input 30% width (reduced from 50%) */
#taskWeeksFromToday {
    max-width: 30%;
    flex: 0 0 30%;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 6px var(--spacing-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 60px;
    padding: 6px var(--spacing-sm);
}

.form-hint {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.3;
}

/* Darker hint text for deadline group */
.deadline-group .form-hint {
    color: var(--text-primary);
    font-weight: 500;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--border-color);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: var(--spacing-md);
        align-items: stretch;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .board {
        flex-direction: column;
    }

    .column {
        min-width: 100%;
        /* Allow free flow on mobile too */
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal-content {
        margin: var(--spacing-md);
        max-height: calc(100vh - 40px);
    }
}

/* Scrollbar Styling */
.column-tasks::-webkit-scrollbar {
    width: 6px;
}

.column-tasks::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.column-tasks::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.column-tasks::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Dashboard Styles */
.dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-lg) var(--spacing-lg) var(--spacing-md);
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.dashboard-header h2 {
    margin: 0;
    font-size: 22px;
}

.dashboard-subtitle {
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 14px;
}

.dashboard-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.dashboard-card {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
}

.dashboard-card.card-warning {
    border-color: var(--danger-color);
    background: #fee2e2;
}

.card-icon {
    font-size: 28px;
}

.card-label {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.dashboard-card h3 {
    margin: 4px 0;
    font-size: 26px;
}

.card-meta {
    font-size: 13px;
    color: var(--text-secondary);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--spacing-sm);
}

.dashboard-panel {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.panel-combined.vertical {
    flex-direction: column;
    gap: var(--spacing-md);
}

.panel-block {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.panel-divider {
    height: 1px;
    width: 100%;
    background: var(--border-color);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.panel-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
}

.distribution-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.distribution-row {
    display: grid;
    grid-template-columns: 90px 1fr 40px;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 13px;
}

.distribution-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 999px;
    overflow: hidden;
}

.distribution-fill {
    height: 100%;
    border-radius: inherit;
}

.priority-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(110px, 1fr));
    gap: var(--spacing-xs);
}

.priority-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    background: var(--bg-secondary);
    text-align: center;
}

.priority-card p {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.priority-card strong {
    display: block;
    font-size: 20px;
    margin-top: 4px;
}

.deadline-list,
.activity-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.deadline-row,
.activity-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
}

.deadline-title,
.activity-title {
    margin: 0;
    font-weight: 600;
    font-size: 14px;
}

.deadline-meta,
.activity-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.deadline-date,
.activity-priority {
    font-weight: 600;
    color: var(--text-primary);
}

.empty-state {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Dashboard Responsive */
@media (min-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .dashboard {
        padding: var(--spacing-md);
    }

    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Footer / Help Section */
.app-footer {
    background-color: var(--bg-primary);
    border-top: 2px solid var(--border-color);
    margin-top: var(--spacing-xl);
    padding: var(--spacing-xl) var(--spacing-lg);
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-xl);
}

.footer-content > .footer-section:has(.help-grid) {
    grid-column: 1 / -1;
}

.footer-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.footer-section:has(.help-grid) {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
}

.footer-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0 0 var(--spacing-sm) 0;
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--border-color);
}

.footer-section h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: var(--spacing-md) 0 var(--spacing-sm) 0;
}

.footer-section p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
}

.footer-section ul,
.footer-section ol {
    margin: var(--spacing-sm) 0;
    padding-left: var(--spacing-lg);
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-secondary);
}

.footer-section li {
    margin-bottom: var(--spacing-xs);
}

.footer-section strong {
    color: var(--text-primary);
    font-weight: 600;
}

.help-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
    margin-top: var(--spacing-sm);
    width: 100%;
    max-width: 100%;
}

.help-item {
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.help-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.help-item h4 {
    margin: 0 0 var(--spacing-xs) 0;
    font-size: 14px;
    color: var(--primary-color);
}

.help-item p {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
}

.footer-bottom {
    max-width: 1400px;
    margin: var(--spacing-xl) auto 0;
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.footer-bottom p {
    margin: 0;
    font-size: 13px;
    color: var(--text-tertiary);
}

/* Footer Responsive */
@media (max-width: 768px) {
    .footer-content {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }

    .help-grid {
        grid-template-columns: 1fr;
    }
}

/* Import Modal Radio Buttons */
#importJsonModal label[for^="importMode"] {
    transition: all 0.2s;
}

#importJsonModal label[for^="importMode"]:hover {
    border-color: var(--primary-color) !important;
    background: var(--bg-secondary);
}

#importJsonModal input[type="radio"]:checked + div strong {
    color: var(--primary-color);
}

#importJsonModal input[type="radio"]:checked {
    accent-color: var(--primary-color);
}

#importJsonModal label:has(input[type="radio"]:checked) {
    border-color: var(--primary-color) !important;
    background: var(--bg-secondary);
}
