/* ========================================
   Scripts Tracker - Node.js v1.1
   ======================================== */

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

body {
    font-family: 'Cairo', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container { max-width: 1200px; margin: 0 auto; }

/* Header */
.header {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.header h1 { color: #667eea; font-size: 2.5rem; margin-bottom: 10px; }
.subtitle { color: #666; font-size: 1.1rem; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.3s;
}

.stat-card:hover { transform: translateY(-5px); }

.stat-number { font-size: 2.5rem; font-weight: bold; color: #667eea; display: block; }
.stat-card.completed .stat-number { color: #10b981; }
.stat-card.in-progress .stat-number { color: #f59e0b; }
.stat-card.pending .stat-number { color: #6b7280; }
.stat-label { color: #666; font-size: 1rem; margin-top: 10px; }

/* Controls */
.controls {
    background: white;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Cairo', sans-serif;
    text-decoration: none;
    display: inline-block;
}

.btn-primary { background: #667eea; color: white; }
.btn-primary:hover { background: #5568d3; }
.btn-secondary { background: #6b7280; color: white; }
.btn-secondary:hover { background: #4b5563; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.search-input, .filter-select {
    flex: 1;
    min-width: 200px;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Cairo', sans-serif;
}

.search-input:focus, .filter-select:focus { outline: none; border-color: #667eea; }

/* Scripts Grid */
.scripts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.script-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: all 0.3s;
    cursor: pointer;
}

.script-card:hover { transform: translateY(-5px); box-shadow: 0 8px 15px rgba(0,0,0,0.15); }
.script-card.completed { border-right: 5px solid #10b981; }
.script-card.in-progress { border-right: 5px solid #f59e0b; }
.script-card.pending { border-right: 5px solid #6b7280; }

.script-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 15px; }
.script-title { font-size: 1.3rem; font-weight: bold; color: #1f2937; margin-bottom: 5px; }

.script-status { padding: 5px 15px; border-radius: 20px; font-size: 0.9rem; font-weight: 600; white-space: nowrap; }
.status-pending { background: #f3f4f6; color: #6b7280; }
.status-in-progress { background: #fef3c7; color: #d97706; }
.status-completed { background: #d1fae5; color: #059669; }

.script-series { color: #667eea; font-size: 0.9rem; margin-bottom: 10px; }
.script-description { color: #4b5563; font-size: 1rem; line-height: 1.6; margin-bottom: 15px; }
.script-meta { display: flex; justify-content: space-between; align-items: center; padding-top: 15px; border-top: 1px solid #e5e7eb; flex-wrap: wrap; gap: 8px; }
.script-duration { color: #6b7280; font-size: 0.9rem; }
.script-meta-left { display: flex; gap: 10px; flex-wrap: wrap; }
.script-actions { display: flex; gap: 8px; }

.action-btn { padding: 6px 12px; border: none; border-radius: 6px; font-size: 0.85rem; cursor: pointer; transition: all 0.3s; font-family: 'Cairo', sans-serif; }
.view-btn { background: #e0e7ff; color: #4338ca; }
.view-btn:hover { background: #c7d2fe; }
.edit-btn { background: #dbeafe; color: #1e40af; }
.edit-btn:hover { background: #bfdbfe; }
.delete-btn { background: #fee2e2; color: #991b1b; }
.delete-btn:hover { background: #fecaca; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding-top: 40px;
    overflow-y: auto;
}

.modal.active { display: flex; }

.modal-content {
    background: white;
    border-radius: 15px;
    width: 95%;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    margin-bottom: 40px;
    animation: modalSlideIn 0.3s ease;
}

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

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    background: white;
    border-radius: 15px 15px 0 0;
    z-index: 1;
}

.modal-header h2 { color: #1f2937; font-size: 1.5rem; }

.close-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #6b7280; padding: 0 5px; }
.close-btn:hover { color: #ef4444; }

/* Form */
.form-group { padding: 12px 20px; }
.form-group label { display: block; margin-bottom: 8px; color: #374151; font-weight: 600; }

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Cairo', sans-serif;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: #667eea; }

.form-group textarea { resize: vertical; min-height: 80px; }

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

.form-actions {
    display: flex;
    gap: 10px;
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    justify-content: flex-end;
    position: sticky;
    bottom: 0;
    background: white;
    border-radius: 0 0 15px 15px;
}

/* Details Page */
.back-nav { margin-bottom: 20px; }

.details-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.details-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 15px; flex-wrap: wrap; }
.details-title { font-size: 2rem; font-weight: bold; color: #1f2937; margin-bottom: 20px; line-height: 1.4; }

.details-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e5e7eb;
}

.meta-item { padding: 8px 16px; background: #f3f4f6; border-radius: 20px; color: #4b5563; font-size: 0.95rem; }

.details-section { margin-bottom: 30px; }
.details-section h2 { font-size: 1.4rem; color: #1f2937; margin-bottom: 15px; display: flex; align-items: center; gap: 8px; }

.description-text {
    color: #4b5563;
    font-size: 1.1rem;
    line-height: 1.8;
    padding: 20px;
    background: #f9fafb;
    border-radius: 10px;
    border-right: 4px solid #667eea;
}

.key-points-list { list-style: none; padding: 0; }

.key-points-list li {
    padding: 12px 45px 12px 20px;
    margin-bottom: 8px;
    background: #f0fdf4;
    border-radius: 8px;
    color: #1f2937;
    font-size: 1.05rem;
    line-height: 1.6;
    position: relative;
    border-right: 3px solid #10b981;
}

.key-points-list li::before {
    content: '✓';
    position: absolute;
    right: 15px;
    top: 12px;
    color: #10b981;
    font-weight: bold;
    font-size: 1.1rem;
}

.details-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e5e7eb;
}

.details-actions .btn { flex: 1; padding: 15px; font-size: 1.1rem; text-align: center; }

/* Script Content Display */
.script-content {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 30px;
    line-height: 1.9;
    color: #1f2937;
    font-size: 1.05rem;
    overflow-x: auto;
}

.script-content h1 { font-size: 2rem; font-weight: 700; color: #1e293b; margin: 1.5em 0 0.5em; border-bottom: 3px solid #667eea; padding-bottom: 0.4em; }
.script-content h2 { font-size: 1.6rem; font-weight: 700; color: #1e293b; margin: 1.3em 0 0.5em; border-bottom: 2px solid #e5e7eb; padding-bottom: 0.3em; }
.script-content h3 { font-size: 1.3rem; font-weight: 600; color: #334155; margin: 1em 0 0.4em; }
.script-content p { margin-bottom: 1em; }
.script-content ul, .script-content ol { padding-right: 2em; margin-bottom: 1em; }
.script-content ul { list-style-type: disc; }
.script-content ol { list-style-type: decimal; }
.script-content li { margin-bottom: 0.5em; line-height: 1.7; }
.script-content strong { font-weight: 700; color: #1e293b; }
.script-content em { font-style: italic; }
.script-content u { text-decoration: underline; }
.script-content s { text-decoration: line-through; color: #6b7280; }
.script-content a { color: #6366f1; text-decoration: underline; }
.script-content a:hover { color: #4f46e5; }
.script-content blockquote { border-right: 4px solid #6366f1; padding: 15px 20px; margin: 1em 0; background: #f5f3ff; border-radius: 0 8px 8px 0; color: #4b5563; }
.script-content pre { background: #1e293b; color: #e2e8f0; padding: 20px; border-radius: 8px; overflow-x: auto; margin: 1em 0; font-family: 'Fira Code', monospace; }
.script-content code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-family: 'Fira Code', monospace; font-size: 0.9em; color: #e11d48; }
.script-content pre code { background: transparent; color: inherit; padding: 0; }
.script-content hr { border: none; border-top: 2px solid #e5e7eb; margin: 2em 0; }
.script-content img { max-width: 100%; border-radius: 8px; }
.script-content table { width: 100%; border-collapse: collapse; margin: 1em 0; }
.script-content th, .script-content td { border: 1px solid #e5e7eb; padding: 12px; text-align: right; }
.script-content th { background: #f8fafc; font-weight: 700; }
.script-content tr:nth-child(even) { background: #f8fafc; }

/* Notification */
.notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 15px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    font-weight: 600;
    font-family: 'Cairo', sans-serif;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
}

.notification.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.notification.success { background: #10b981; color: white; }
.notification.error { background: #ef4444; color: white; }

/* Quill Editor */
.quill-editor { min-height: 350px; background: #ffffff; }

.ql-toolbar.ql-snow {
    border: 2px solid #e5e7eb !important;
    border-bottom: none !important;
    border-radius: 10px 10px 0 0 !important;
    background: #f9fafb !important;
    padding: 10px !important;
}

.ql-container.ql-snow {
    border: 2px solid #e5e7eb !important;
    border-radius: 0 0 10px 10px !important;
    font-family: 'Cairo', sans-serif !important;
    font-size: 16px !important;
    min-height: 350px !important;
    direction: rtl !important;
}

.ql-editor { direction: rtl !important; text-align: right !important; padding: 20px !important; line-height: 1.8 !important; }
.ql-editor.ql-blank::before { right: 20px !important; font-style: normal !important; color: #9ca3af !important; }

.ql-snow .ql-stroke { stroke: #4b5563 !important; }
.ql-snow .ql-fill { fill: #4b5563 !important; }
.ql-snow .ql-toolbar button:hover .ql-stroke { stroke: #667eea !important; }
.ql-snow .ql-toolbar button:hover .ql-fill { fill: #667eea !important; }
.ql-snow .ql-toolbar button.ql-active .ql-stroke { stroke: #667eea !important; }
.ql-snow .ql-toolbar button.ql-active .ql-fill { fill: #667eea !important; }
.ql-snow .ql-picker-label { color: #4b5563 !important; }
.ql-snow .ql-picker-label:hover { color: #667eea !important; }
.ql-snow .ql-picker-options { border-radius: 8px !important; box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important; }

/* Empty State */
.empty-state { text-align: center; padding: 60px 20px; color: #6b7280; grid-column: 1 / -1; }
.empty-state-icon { font-size: 4rem; margin-bottom: 20px; }
.empty-state-text { font-size: 1.3rem; margin-bottom: 10px; color: #374151; }
.empty-state-subtext { font-size: 1rem; color: #9ca3af; }

/* Loading */
.loading { text-align: center; padding: 40px; grid-column: 1 / -1; color: white; font-size: 1.2rem; }

/* Responsive */
@media (max-width: 768px) {
    .header h1 { font-size: 1.8rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .controls { flex-direction: column; }
    .scripts-grid { grid-template-columns: 1fr; }
    .script-header { flex-direction: column; }
    .script-meta { flex-direction: column; align-items: flex-start; }
    .details-title { font-size: 1.5rem; }
    .details-actions { flex-direction: column; }
    .form-row { grid-template-columns: 1fr; }
    .modal-content { width: 100%; max-height: 100vh; border-radius: 0; margin: 0; }
}
