/* Modern UI Overhaul for Silico Ticketing System - FINAL & CORRECTED VERSION 2 */

:root {
    --primary-color: #4a90e2; /* A professional and friendly blue */
    --primary-hover-color: #357abd;
    --background-color: #f4f7f9; /* A very light, clean grey */
    --card-background-color: #ffffff;
    --text-color: #333333;
    --text-light-color: #667c99;
    --border-color: #e1e8ed;
    --shadow-color: rgba(0, 0, 0, 0.05);

    --status-open-bg: #fffbe6;
    --status-open-text: #f59e0b;
    --status-open-dot: #f59e0b;

    --status-progress-bg: #eef2ff;
    --status-progress-text: #6366f1;
    --status-progress-dot: #6366f1;
    
    --status-cancelled-bg: #fef2f2;
    --status-cancelled-text: #dc2626;
    --status-cancelled-dot: #dc2626;
    
    --status-resolved-bg: #f0fdf4;
    --status-resolved-text: #22c55e;
    --status-resolved-dot: #22c55e;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-color);
    margin-bottom: 20px;
    font-weight: 600;
}

.card {
    background-color: var(--card-background-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow-color);
    padding: 30px;
    margin-bottom: 30px;
}

/* Navigation Bar */
.navbar {
    background-color: #174952;
    padding: 15px 0;
    box-shadow: 0 2px 4px var(--shadow-color);
    border-bottom: 1px solid var(--border-color);
}
.nav-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Logo text */
.nav-logo a {
    color: #ffffff; /* Bright for contrast against dark teal */
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: 700;
    transition: text-shadow 0.3s ease;
}

/* Add glow on hover for logo too */
.nav-logo a:hover {
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

/* Nav links layout */
.nav-links {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 25px;
}

/* Nav link appearance */
.nav-links a {
    color: #ffffff; /* Light cyan for a cool contrast on dark teal */
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

/* Hover and active styles with glow */
.nav-links a:hover,
.nav-links a.active {
    color: #ffffff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}


/* Enhanced Flash Messages */
.flashes { 
    list-style: none; 
    padding: 0; 
    margin: 20px 0; 
}

.flashes li {
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: 8px;
    font-weight: 500;
    border-left: 4px solid;
}

.flashes .flash-success {
    background-color: #f0fdf4;
    color: #166534;
    border-left-color: #22c55e;
}

.flashes .flash-error {
    background-color: #fef2f2;
    color: #dc2626;
    border-left-color: #ef4444;
}

.flashes .flash-default {
    background-color: var(--primary-hover-color);
    color: #fff;
    border-left-color: var(--primary-color);
}

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; color: var(--text-color); }
.form-control { width: 100%; padding: 12px; border: 1px solid var(--border-color); border-radius: 8px; box-sizing: border-box; font-size: 1rem; color: var(--text-color); background-color: #fff; transition: border-color 0.3s ease, box-shadow 0.3s ease; }
.form-control:focus { border-color: var(--primary-color); outline: none; box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2); }

/* Buttons */
.btn { display: inline-block; background-color: var(--primary-color); color: #fff; padding: 12px 24px; border: none; border-radius: 8px; cursor: pointer; font-size: 1rem; font-weight: 600; text-align: center; text-decoration: none; transition: background-color 0.3s ease, transform 0.2s ease; }
.btn:hover { background-color: var(--primary-hover-color); transform: translateY(-2px); }
.btn-success { background-color: #22c55e; }
.btn-success:hover { background-color: #16a34a; }
.btn-danger { background-color: #ef4444; }
.btn-danger:hover { background-color: #dc2626; }
.btn-secondary { background-color: var(--text-light-color); }
.btn-secondary:hover { background-color: #55667d; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

/* Tables */
.ticket-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
.ticket-table th, .ticket-table td { padding: 15px; text-align: left; border-bottom: 1px solid var(--border-color); }
.ticket-table th { font-weight: 600; color: var(--text-light-color); font-size: 0.9rem; text-transform: uppercase; }
.ticket-table tbody tr:hover { background-color: var(--background-color); }

/* Status Labels */
.status-badge { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 9999px; font-weight: 500; font-size: 0.85rem; }
.status-badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }
.status-Open { background-color: var(--status-open-bg); color: var(--status-open-text); }
.status-Open::before { background-color: var(--status-open-dot); }
.status-In-Progress { background-color: var(--status-progress-bg); color: var(--status-progress-text); }
.status-In-Progress::before { background-color: var(--status-progress-dot); }
.status-Resolved { background-color: var(--status-resolved-bg); color: var(--status-resolved-text); }
.status-Resolved::before { background-color: var(--status-resolved-dot); }
.status-Cancelled { background-color: var(--status-cancelled-bg); color: var(--status-cancelled-text); }
.status-Cancelled::before { background-color: var(--status-cancelled-dot); }
.status-Cancelled-by-User { background-color: var(--status-cancelled-bg); color: var(--status-cancelled-text); }
.status-Cancelled-by-User::before { background-color: var(--status-cancelled-dot); }

/* General Ticket View Styles */
.ticket-header { margin-bottom: 30px; border-bottom: 1px solid var(--border-color); padding-bottom: 20px; }
.ticket-header h2 { font-size: 2rem; margin: 0; }
.ticket-meta { display: flex; gap: 20px; color: var(--text-light-color); margin-top: 10px; flex-wrap: wrap; }
.ticket-meta span { display: flex; align-items: center; gap: 8px; }
.image-block { max-width: 100%; height: auto; margin-top: 15px; border-radius: 8px; border: 1px solid var(--border-color); }

/* === REBUILT & FINAL TIMELINE STYLES === */
.ticket-timeline-container { margin-top: 20px; }

ul.ticket-timeline {
    list-style-type: none;
    margin: 0;
    padding: 0;
    position: relative;
}

ul.ticket-timeline > li {
    position: relative;
    /* Create space on the left for the gutter (timestamp + line) */
    padding-left: 140px; 
    margin-bottom: 30px;
}

/* Vertical Line - Pseudo-element on the LI */
ul.ticket-timeline > li::before {
    content: ' ';
    position: absolute;
    z-index: 0;
    left: 110px; /* Position within the padding area */
    top: 5px;   /* Start just below the top of the LI */
    height: calc(100% + 30px); /* Extend into the next item's margin */
    width: 2px;
    background-image: linear-gradient(var(--border-color) 60%, rgba(255,255,255,0) 0%);
    background-position: left;
    background-size: 2px 10px;
    background-repeat: repeat-y;
}

/* Last item should not have a continuing line */
ul.ticket-timeline > li:last-child::before {
    height: 23px; /* Stop exactly at the node center (5px top + 18px node height / 2) */
}

/* Circular Node - Also a pseudo-element on the LI */
ul.ticket-timeline > li::after {
    content: ' ';
    position: absolute;
    z-index: 1;
    left: 102px; /* Center the node on the line (110px line position - 8px half-width) */
    top: 5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 3px solid var(--card-background-color);
    transition: all 0.2s ease-out;
}
ul.ticket-timeline > li:hover::after {
    transform: scale(1.1);
}

/* Node colors for different actors */
ul.ticket-timeline > li.timeline-item--user::after { background-color: #ef4444; } /* Red for posting */
ul.ticket-timeline > li.timeline-item--admin::after { background-color: var(--status-progress-text); }

/* Node colors for different ticket statuses */
ul.ticket-timeline > li.timeline-item--posting::after { 
    background-color: #ef4444; /* Red for posting */
}
ul.ticket-timeline > li.timeline-item--in-progress::after { 
    background-color: #f59e0b; /* Yellow for in progress */
}
ul.ticket-timeline > li.timeline-item--resolved::after { 
    background-color: #22c55e; /* Green for resolved */
}
ul.ticket-timeline > li.timeline-item--cancelled::after { 
    background-color: #dc2626; /* Red for cancelled */
}

/* Glow effect only for the last timeline item */
ul.ticket-timeline > li:last-child.timeline-item--posting::after {
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4), 0 0 16px rgba(239, 68, 68, 0.2);
}
ul.ticket-timeline > li:last-child.timeline-item--in-progress::after {
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4), 0 0 16px rgba(245, 158, 11, 0.2);
}
ul.ticket-timeline > li:last-child.timeline-item--resolved::after {
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4), 0 0 16px rgba(34, 197, 94, 0.2);
}
ul.ticket-timeline > li:last-child.timeline-item--cancelled::after {
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.4), 0 0 16px rgba(220, 38, 38, 0.2);
}


.timeline-timestamp {
    position: absolute;
    left: 0; /* Position at the very start of the padding area */
    top: 2px;
    text-align: right;
    width: 95px;
    font-size: 0.85rem;
    color: var(--text-light-color);
    font-weight: 500;
}

/* The card itself needs no special positioning */
.timeline-card {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    /* The card starts naturally after the 140px padding on the LI */
}

.timeline-card-header { font-weight: 600; margin-bottom: 10px; }
.timeline-card-header .actor { color: var(--text-color); }
.timeline-card-body p { margin: 0 0 10px 0; white-space: pre-wrap; overflow-wrap: break-word; }
.timeline-card-body .image-block { margin-top: 10px; max-width: 400px; }
/* === END OF REBUILT TIMELINE === */


/* --- Styles for the dynamic "Add Entry" on Create Ticket page --- */
.add-entry-controls { display: flex; justify-content: center; margin-top: 20px; }
.dynamic-entry-card { background: #f9fafb; border: 1px solid var(--border-color); border-radius: 8px; padding: 20px; margin-top: 20px; animation: fadeIn 0.4s ease-out; position: relative; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.dynamic-entry-card .entry-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.dynamic-entry-card .entry-header select { max-width: 180px; }
.custom-file-input-wrapper { border: 2px dashed var(--border-color); border-radius: 8px; padding: 20px; text-align: center; cursor: pointer; position: relative; transition: background-color 0.3s ease, border-color 0.3s ease; }
.custom-file-input-wrapper:hover { background-color: var(--status-progress-bg); border-color: var(--primary-color); }
.custom-file-input-wrapper input[type="file"] { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.custom-file-input-wrapper .file-name-display { color: var(--primary-color); font-weight: 500; margin-top: 10px; }
.custom-file-input-wrapper .upload-text { color: var(--text-light-color); font-weight: 500; }

/* Enhanced UI Improvements */

/* Improved Dashboard Filters */
.filter-sort-controls {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--card-background-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.filter-sort-controls label {
    font-weight: 600;
    color: var(--text-color);
    margin-right: 10px;
}

.filter-sort-controls select,
.filter-sort-controls input[type="text"] {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
    transition: all 0.3s ease;
}

.filter-sort-controls select:focus,
.filter-sort-controls input[type="text"]:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
    outline: none;
}

.status-filter-form {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Enhanced Table Styling */
.ticket-table {
    background: var(--card-background-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px var(--shadow-color);
    border: 1px solid var(--border-color);
}

.ticket-table th {
    background: var(--background-color);
    font-weight: 600;
    color: var(--text-color);
    padding: 18px 15px;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.ticket-table td {
    padding: 16px 15px;
    vertical-align: middle;
}

.ticket-table tbody tr {
    transition: background-color 0.2s ease;
}

.ticket-table tbody tr:hover {
    background-color: rgba(74, 144, 226, 0.05);
}

/* Status badges in tables */
.ticket-table .status-badge {
    font-size: 0.8rem;
    padding: 4px 10px;
}

/* Enhanced Form Styling */
.card form {
    margin-top: 0;
}

.form-group input,
.form-group select,
.form-group textarea {
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: rgba(74, 144, 226, 0.3);
}

/* Login/Register Form Enhancements */
.auth-container {
    max-width: 450px;
    margin: 60px auto;
    padding: 40px;
    background: var(--card-background-color);
    border-radius: 16px;
    box-shadow: 0 8px 24px var(--shadow-color);
    border: 1px solid var(--border-color);
}

.auth-container h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-color);
    font-size: 1.8rem;
}

.auth-container .form-group {
    margin-bottom: 24px;
}

.auth-container .form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-color);
}

.auth-container .form-group input {
    padding: 14px 16px;
    font-size: 1rem;
}

.auth-container .btn {
    width: 100%;
    padding: 14px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 10px;
}

.auth-container p {
    text-align: center;
    margin-top: 24px;
    color: var(--text-light-color);
}

.auth-container a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.auth-container a:hover {
    text-decoration: underline;
}

/* Enhanced Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.action-buttons .btn {
    font-size: 0.85rem;
    padding: 8px 16px;
}

/* Page Headers */
.page-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.page-header h2 {
    margin: 0;
    color: var(--text-color);
    font-size: 2.2rem;
    font-weight: 700;
}

.page-header p {
    margin: 8px 0 0 0;
    color: var(--text-light-color);
    font-size: 1.1rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light-color);
}

.empty-state h3 {
    color: var(--text-color);
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 24px;
}

.empty-state .btn {
    margin-top: 10px;
}

/* User Cancel Section */
.user-cancel-section {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 25px;
    margin-top: 30px;
}

.user-cancel-section h3 {
    color: #dc2626;
    margin-bottom: 12px;
    font-size: 1.3rem;
}

.user-cancel-section p {
    color: #7f1d1d;
    line-height: 1.6;
}

.user-cancel-section .btn-danger {
    background-color: #dc2626;
    border: none;
    padding: 12px 24px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.user-cancel-section .btn-danger:hover {
    background-color: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

/* Enhanced Flash Messages */