/* ==================== VARIABLES CSS ==================== */
:root {
    --primary-color: #2196F3;
    --primary-dark: #1976D2;
    --success-color: #4CAF50;
    --warning-color: #FF9800;
    --danger-color: #F44336;
    --secondary-color: #757575;
    --background: #f5f7fa;
    --surface: #ffffff;
    --text-primary: #212121;
    --text-secondary: #757575;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --radius: 8px;
    --transition: all 0.3s ease;
}

/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ==================== HEADER ==================== */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1.5rem 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.15);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    animation: pulse 2s infinite;
}

.connection-status.connected .status-dot {
    background: #4CAF50;
}

.connection-status.error .status-dot {
    background: #F44336;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==================== CONTAINER ==================== */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

.main-container {
    padding: 20px;
}

/* ==================== CARDS ==================== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body {
    padding: 20px;
}

/* ==================== FILTERS ==================== */
.filters-row {
    display: flex;
    align-items: flex-end;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.filters-row:last-child {
    margin-bottom: 0;
}

/* ==================== CONTENT GRID ==================== */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 650px;
    gap: 20px;
}

/* ==================== TABLE ==================== */
.table-container {
    overflow-x: auto;
    max-height: calc(100vh - 400px);
}

.tasks-table {
    width: 100%;
    border-collapse: collapse;
}

.tasks-table thead {
    position: sticky;
    top: 0;
    background: var(--primary-color);
    color: white;
    z-index: 10;
}

.tasks-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
}

.tasks-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.tasks-table tbody tr {
    transition: var(--transition);
    cursor: pointer;
}

.tasks-table tbody tr:hover {
    background-color: #f5f5f5;
}

.tasks-table tbody tr.selected {
    background-color: #e3f2fd !important;
    border-left: 4px solid var(--primary-color);
}

.tasks-table tbody tr.task-assigned {
    background-color: #fff9c4 !important;
    border-left: 4px solid var(--warning-color);
}

.tasks-table tbody tr.task-assigned:hover {
    background-color: #fff59d !important;
}

.checkbox-col {
    width: 40px;
    text-align: center;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.no-data {
    text-align: center;
    padding: 40px !important;
    color: var(--text-secondary);
}

/* ==================== FORM ==================== */
.form-scroll {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding-right: 5px;
}

.form-section {
    margin-bottom: 24px;
    background: #fafafa;
    border-radius: var(--radius);
    padding: 20px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.section-title .template-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 0.9rem;
}

.btn-icon:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

/* ==================== TEXTAREA MEJORADO ==================== */
textarea {
    resize: vertical;
    min-height: 200px;
    line-height: 1.8;
    font-size: 1rem !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    padding: 16px !important;
    width: 100% !important;
    border: 2px solid var(--border-color) !important;
    border-radius: var(--radius) !important;
    background: white !important;
    transition: var(--transition);
}

textarea:focus {
    outline: none !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1) !important;
}

textarea:disabled {
    background-color: #f5f5f5 !important;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Específico para el textarea de observaciones */
#observaciones {
    min-height: 180px;
    max-height: 400px;
    font-size: 0.95rem !important;
}

/* ==================== TIME SECTION ==================== */
.time-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.time-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.time-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.time-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.time-controls input {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
    background: white;
    transition: var(--transition);
}

.time-controls input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.time-buttons {
    display: flex;
    gap: 6px;
}

.btn-time {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-secondary);
}

.btn-time:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.2);
}

/* ==================== CONFIG GRID ==================== */
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.config-item label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.config-item select {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    background: white;
    cursor: pointer;
    transition: var(--transition);
}

.config-item select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.config-item select:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

/* ==================== INFO BOX ==================== */
.info-box {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 2px solid #2196F3;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 24px;
}

.info-box-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(33, 150, 243, 0.3);
}

.info-content {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.6;
    white-space: pre-wrap;
}

/* ==================== TEMPLATES ==================== */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.template-btn {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-weight: 500;
}

.template-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.2);
}

.template-btn i {
    font-size: 1rem;
    opacity: 0.7;
}

.template-btn:hover i {
    opacity: 1;
}

/* ==================== BUTTONS ==================== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #D32F2F;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #fb8c00;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #616161;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-edit {
    background: #2196F3;
    color: white;
}

.btn-add {
    background: #9C27B0;
    color: white;
}

.btn-large {
    width: 100%;
    padding: 18px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 8px;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-large:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.btn-large span {
    font-weight: 700;
    letter-spacing: 0.5px;
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.btn-close:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-primary);
}

/* ==================== TASK COUNTER ==================== */
.task-counter {
    padding: 10px 20px;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-radius: var(--radius);
    font-weight: 600;
    color: var(--primary-dark);
}

/* ==================== MODALS ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 700px;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.templates-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.template-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.template-item-info {
    flex: 1;
}

.template-item-info strong {
    display: block;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.template-item-info p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

.template-item-actions {
    display: flex;
    gap: 8px;
}

/* ==================== ALERTS ==================== */
.alert {
    position: fixed;
    top: 80px;
    right: 20px;
    min-width: 300px;
    padding: 15px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    z-index: 3000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.alert-success {
    background: #4CAF50;
    color: white;
}

.alert-error {
    background: #F44336;
    color: white;
}

.alert-warning {
    background: #FF9800;
    color: white;
}

.alert .fas {
    font-size: 1.25rem;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1400px) {
    .content-grid {
        grid-template-columns: 1fr 600px;
    }
}

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .form-card {
        order: -1;
    }
    
    .form-scroll {
        max-height: 600px;
    }
    
    .templates-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.25rem;
    }
    
    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .time-grid,
    .config-grid {
        grid-template-columns: 1fr;
    }
    
    .templates-grid {
        grid-template-columns: 1fr;
    }
    
    .table-container {
        max-height: 400px;
    }
    
    .form-scroll {
        max-height: none;
    }
    
    .time-buttons {
        flex-wrap: wrap;
    }
    
    .btn-time {
        min-width: 70px;
    }
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.form-scroll::-webkit-scrollbar {
    width: 6px;
}

.form-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.form-scroll::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.form-scroll::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ==================== UTILITIES ==================== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }