/* Scheduling Visualizer Styles */
:root {
    --primary-blue: #1e3a8a;
    --secondary-blue: #3b82f6;
    --light-blue: #dbeafe;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-900: #111827;
    --success-green: #10b981;
    --warning-orange: #f59e0b;
    --danger-red: #ef4444;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    overflow-x: hidden;
}

header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-buttons {
    display: flex;
    gap: 15px;
    align-items: center;
}

h1 {
    color: var(--primary-blue);
    font-size: 28px;
}

.back-link {
    color: var(--secondary-blue);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 16px;
    border: 1px solid var(--secondary-blue);
    border-radius: 4px;
    transition: all 0.3s;
}

.back-link:hover {
    background: var(--secondary-blue);
    color: white;
}

.main-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.controls-section,
.visualization-section,
.explanation-section {
    background: white;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    overflow: visible;
}

.left-column {
    display: flex;
    flex-direction: column;
}

.right-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.top-row {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 15px;
}

.summary-section,
.simulation-section {
    background: white;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.simulation-section {
    background: #f0fdf4;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.simulation-section .control-item {
    margin-bottom: 10px;
}

.simulation-section input[type="date"],
.simulation-section input[type="number"] {
    font-size: 13px;
}

.visualization-section {
    overflow: hidden;
    min-width: 0; /* Prevent grid blowout */
    flex: 1;
    background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
    border: 1px solid rgba(59, 130, 246, 0.1);
    position: relative;
    padding: 15px;
}

.visualization-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, 
        #ef4444 0%, 
        #3b82f6 33%, 
        #10b981 66%, 
        #ef4444 100%);
    opacity: 0.6;
}

h2 {
    color: var(--primary-blue);
    font-size: 18px;
    margin-bottom: 15px;
}

.visualization-section h2 {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-blue), var(--secondary-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-fill-color: transparent;
    position: relative;
    z-index: 10;
}

h3 {
    color: var(--gray-700);
    font-size: 14px;
    margin-bottom: 10px;
    margin-top: 0;
    font-weight: 600;
}

.control-group {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--gray-200);
}

.control-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.control-item {
    margin-bottom: 8px;
}

.control-item small {
    display: block;
    color: var(--gray-700);
    font-size: 12px;
    margin-top: 4px;
    margin-left: 20px;
}

.control-item label {
    display: block;
    font-weight: 500;
    margin-bottom: 3px;
    color: var(--gray-700);
    font-size: 13px;
}

.control-item select,
.control-item input[type="number"],
.control-item input[type="date"] {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 13px;
    background: white;
}

/* Inline inputs */
.control-item input[type="number"]:not(.full-width) {
    width: 80px;
    display: inline-block;
}

.control-item select:not(.full-width) {
    width: auto;
    display: inline-block;
}

.control-item input[type="checkbox"],
.control-item input[type="radio"] {
    margin-right: 8px;
}

.control-item label input[type="checkbox"] {
    display: inline;
    width: auto;
}

#calendar-interval-value {
    width: 70%;
    margin-right: 5%;
}

#calendar-interval-unit {
    width: 25%;
}

.primary-button {
    width: 100%;
    padding: 12px;
    background: var(--secondary-blue);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.3s;
}

.primary-button:hover {
    background: var(--primary-blue);
}

.secondary-button {
    padding: 6px 12px;
    background: var(--success-green);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}

.secondary-button:hover {
    background: #059669;
}

.simulation-group {
    background: #f0fdf4;
    border: 1px solid var(--success-green);
    border-radius: 6px;
    padding: 15px;
    margin-top: 20px;
}

.simulation-result {
    background: white;
    padding: 10px;
    border-radius: 4px;
    margin-top: 10px;
    border: 1px solid var(--gray-200);
}

#new-sensor-value {
    flex: 1;
}

#timeline-container {
    height: 300px;
    margin-bottom: 30px;
    width: 100%;
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.schedule-details {
    max-height: 400px;
    overflow-y: auto;
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.task-item {
    background: var(--gray-100);
    padding: 15px;
    border-radius: 6px;
    border: 1px solid var(--gray-200);
    transition: all 0.2s;
}

.task-item:hover {
    border-color: var(--secondary-blue);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.task-item.overdue {
    background: #fef3c7;
    border-color: var(--warning-orange);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.task-number {
    font-weight: 600;
    color: var(--gray-900);
}

.task-trigger {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.task-trigger.calendar {
    background: var(--light-blue);
    color: var(--primary-blue);
}

.task-trigger.sensor {
    background: #fee2e2;
    color: #dc2626;
}

.task-dates {
    font-size: 14px;
    color: var(--gray-700);
}

.task-dates > div {
    margin-bottom: 4px;
}

.task-dates strong {
    margin-right: 5px;
}

#logic-explanation {
    white-space: pre-line;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 12px;
    background: var(--gray-100);
    padding: 10px;
    border-radius: 4px;
    line-height: 1.6;
    max-height: 150px;
    overflow-y: auto;
}

/* Responsive design */
@media (max-width: 1024px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    
    .visualization-section {
        grid-column: 1;
        grid-row: 2;
    }
    
    .explanation-section {
        grid-row: 3;
    }
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Updating indicator */
.updating-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--secondary-blue);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    display: none;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.updating-indicator.show {
    display: block;
}

/* Chart controls */
.chart-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px;
    background: var(--gray-100);
    border-radius: 4px;
}

.chart-controls button {
    padding: 6px 12px;
    background: var(--secondary-blue);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.chart-controls button:hover {
    background: var(--primary-blue);
}

.zoom-hint {
    font-size: 12px;
    color: var(--gray-700);
    font-style: italic;
}

.task-item.more {
    text-align: center;
    font-style: italic;
    color: var(--gray-700);
    background: var(--gray-100);
    padding: 10px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.task-item {
    animation: fadeIn 0.3s ease-out;
}

/* Compact radio groups */
.radio-group {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

.radio-inline {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    cursor: pointer;
}

.radio-inline input[type="radio"] {
    margin-right: 5px;
}

/* Inline controls */
.inline-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inline-controls input[type="number"] {
    width: 80px !important;
}

.inline-controls select {
    width: auto !important;
}

/* Compact header */
header {
    padding: 15px 20px;
}

header h1 {
    font-size: 22px;
}

/* Smaller timeline */
#timeline-container {
    height: 423px;
    padding: 0;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    position: relative;
}

/* Compact schedule details */
.schedule-details {
    background: white;
    padding: 0;
    border-radius: 8px;
    overflow: visible;
}

.schedule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid var(--gray-200);
}

.schedule-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--gray-900);
}

.schedule-actions {
    display: flex;
    gap: 10px;
}

.btn-secondary {
    padding: 6px 12px;
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.schedule-summary {
    display: flex;
    gap: 20px;
    padding: 8px 15px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.summary-label {
    font-size: 12px;
    color: var(--gray-600);
}

.summary-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
}

.task-table-container {
    overflow-x: auto;
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: 0 0 8px 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) var(--gray-100);
}

.task-table-container::-webkit-scrollbar {
    width: 8px;
}

.task-table-container::-webkit-scrollbar-track {
    background: var(--gray-100);
}

.task-table-container::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

.task-table-container::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

.task-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.task-table thead {
    position: sticky;
    top: 0;
    background: var(--gray-50);
    z-index: 10;
}

.task-table th {
    text-align: left;
    padding: 8px 10px;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
    font-size: 11px;
    text-transform: uppercase;
}

.task-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--gray-100);
}

.task-table tbody tr:hover {
    background: var(--gray-50);
}

.task-table tr.overdue {
    background: rgba(239, 68, 68, 0.05);
}

.task-table tr.soon {
    background: rgba(245, 158, 11, 0.05);
}

.task-number {
    font-weight: 600;
    color: var(--gray-900);
}

.task-type-cell {
    text-align: center;
}

.task-icon {
    font-size: 16px;
    cursor: help;
}

.days-until {
    font-weight: 500;
}

.days-until .overdue {
    color: var(--danger-red);
}

.days-until .today {
    color: var(--warning-orange);
    font-weight: 600;
}

.days-until .tomorrow {
    color: var(--warning-orange);
}

.trigger-info {
    color: var(--gray-600);
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}

.status-overdue {
    background: var(--danger-red);
    color: white;
}

.status-soon {
    background: var(--warning-orange);
    color: white;
}

.status-upcoming {
    background: var(--gray-200);
    color: var(--gray-700);
}

.table-footer {
    padding: 15px 20px;
    text-align: center;
    color: var(--gray-600);
    font-size: 13px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* Old task-item styles removed - using table now */

/* Compact primary button */
.primary-button {
    padding: 10px 16px;
    font-size: 14px;
    margin-top: 15px;
}

/* Starting point highlight */
.control-item.date-used {
    border-left: 3px solid var(--secondary-blue);
    padding-left: 10px;
    background: var(--light-blue);
    border-radius: 4px;
    margin-left: -10px;
}

/* Date input with clear button */
.date-input-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.date-input-wrapper input[type="date"] {
    padding-right: 30px;
    width: 100%;
}

.date-clear-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--gray-400);
    font-size: 18px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.date-clear-btn:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.date-clear-btn:active {
    background: var(--gray-200);
}

/* Adjust full-width class for date inputs in wrappers */
.date-input-wrapper input.full-width {
    width: 100%;
}

/* Feedback Button and Modal Styles */
.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.feedback-button {
    padding: 8px 16px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #f59e0b;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.feedback-button:hover {
    background: #fed7aa;
    border-color: #ea580c;
}

.bug-icon {
    font-size: 16px;
}

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

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: var(--gray-900);
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-body p {
    margin: 0 0 15px 0;
    color: var(--gray-700);
}

.feedback-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
}

.feedback-textarea:focus {
    outline: none;
    border-color: var(--secondary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.feedback-info {
    margin-top: 10px;
}

.feedback-info small {
    color: var(--gray-600);
    font-size: 12px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-footer .btn-secondary {
    padding: 8px 16px;
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-footer .btn-secondary:hover {
    background: var(--gray-200);
    border-color: var(--gray-400);
}

.modal-footer .btn-primary {
    padding: 8px 16px;
    background: var(--secondary-blue);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}

.modal-footer .btn-primary:hover {
    background: var(--primary-blue);
}
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.feedback-button:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.bug-icon {
    font-size: 16px;
}

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

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    color: var(--primary-blue);
    font-size: 20px;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.modal-body {
    padding: 20px;
}

.modal-body p {
    margin-bottom: 15px;
    color: var(--gray-700);
}

.feedback-textarea {
    width: 100%;
    min-height: 120px;
    padding: 10px;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
}

.feedback-textarea:focus {
    outline: none;
    border-color: var(--secondary-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.feedback-info {
    margin-top: 10px;
}

.feedback-info small {
    color: var(--gray-600);
    font-size: 12px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.button {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: all 0.3s;
}

.primary-button {
    background: var(--secondary-blue);
    color: white;
}

.primary-button:hover {
    background: var(--primary-blue);
}

.secondary-button {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.secondary-button:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}