@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary-color: #4f46e5;
    --primary-light: #6366f1;
    --primary-dark: #4338ca;
    
    --bg-light: #f8fafc;
    --bg-medium: #e2e8f0;
    --bg-dark: #f1f5f9;
    
    --text-dark: #1e293b;
    --text-medium: #475569;
    --text-light: #64748b;
    
    --border-color: #cbd5e1;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    
    --radius-md: 12px;
    --sidebar-width: 260px;
}

/* --- GLOBAL RESET --- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    overflow-x: hidden;
    min-height: 100vh;
    width: 100%;
}

/* --- SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: white;
    border-right: 1px solid var(--border-color);
    padding: 30px 20px;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1050; /* High z-index to sit above content on mobile */
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
/* --- LAYOUT STRUCTURE --- */
.app-layout { display: flex; width: 100%; min-height: 100vh; position: relative; }



.brand {
    font-size: 1.5rem; font-weight: 800; color: var(--primary-color);
    margin-bottom: 40px; display: flex; align-items: center; gap: 10px;
}

.nav-link {
    display: flex; align-items: center; gap: 12px; padding: 12px 15px;
    color: var(--text-medium); text-decoration: none; font-weight: 500;
    border-radius: 8px; margin-bottom: 6px; transition: all 0.2s ease;
}
.nav-link:hover { background-color: var(--bg-medium); color: var(--primary-color); }
.nav-link.active { background-color: var(--primary-color); color: white; }

/* --- MAIN CONTENT --- */
.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    padding: 30px 40px;
    background-color: var(--bg-dark);
    min-height: 100vh;
    transition: margin-left 0.3s ease, width 0.3s ease;
}

/* --- HEADER AREA --- */
.header-area {
    display: flex; justify-content: space-between; align-items: center;
    background-color: white; padding: 20px 25px; border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm); margin-bottom: 30px; gap: 20px; flex-wrap: wrap;
}
.header-area h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 5px; }
.header-area p { color: var(--text-light); font-size: 0.9rem; }

/* --- BUTTONS & INPUTS --- */
.btn-primary-custom {
    background-color: var(--primary-color); color: white; border: none;
    padding: 10px 20px; border-radius: 50px; font-weight: 600; cursor: pointer;
    transition: transform 0.2s; white-space: nowrap;
}
.btn-primary-custom:hover { background-color: var(--primary-dark); transform: translateY(-2px); }

.search-form {
    display: flex; align-items: center; background: #f1f5f9; border: 1px solid transparent;
    border-radius: 50px; padding: 5px 15px; width: 300px; max-width: 100%;
}
.search-form:focus-within { background: white; border-color: var(--primary-color); }
.search-input { border: none; outline: none; background: transparent; flex: 1; padding: 5px; }

/* --- TICKET ROWS (Cards) --- */
.ticket-container { display: flex; flex-direction: column; gap: 15px; width: 100%; }
.ticket-row {
    background-color: white; border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border-color);
    width: 100%; transition: all 0.3s ease;
}
.ticket-row:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary-color); }

.ticket-header {
    padding: 15px 20px; display: flex; align-items: center; justify-content: space-between;
    width: 100%; cursor: pointer; gap: 15px;
}

.ticket-info-left { display: flex; align-items: center; gap: 15px; flex: 1; min-width: 0; /* Prevents flex items from overflowing */ }
.status-icon { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; flex-shrink: 0; }
.bg-soft-blue { background-color: #6366f1; } .bg-soft-red { background-color: #ef4444; } .bg-soft-green { background-color: #22c55e; }

.ticket-title h4 {
    font-size: 1rem; font-weight: 600; margin: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ticket-meta-right { display: flex; align-items: center; gap: 25px; flex-shrink: 0; }
.date-group { display: flex; flex-direction: column; align-items: flex-end; }
.date-label { font-size: 0.65rem; text-transform: uppercase; color: var(--text-light); font-weight: 700; }
.date-value { font-size: 0.85rem; font-weight: 500; color: var(--text-medium); }

.action-group { display: flex; gap: 8px; }
.btn-icon {
    width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border-color);
    background: white; color: var(--text-light); display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: 0.2s;
}
.btn-icon:hover { background: var(--primary-color); color: white; border-color: var(--primary-color); }
.btn-icon.delete:hover { background: #ef4444; border-color: #ef4444; }

.toggle-arrow { margin-left: 10px; color: var(--text-light); }
.ticket-row.open .toggle-arrow { transform: rotate(180deg); }

/* --- COMMENTS --- */
.ticket-body { max-height: 0; overflow: hidden; background-color: #fcfcfc; border-top: 1px solid var(--border-color); transition: max-height 0.5s ease; }
.ticket-row.open .ticket-body { max-height: 1000px; } /* Increased height to accommodate more comments */
.comments-wrapper { padding: 20px; }
.comment-item { display: flex; gap: 15px; margin-bottom: 15px; }
.avatar { width: 30px; height: 30px; background: #6366f1; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; flex-shrink: 0; }
.comment-bubble { background: white; padding: 10px 15px; border: 1px solid var(--border-color); border-radius: 0 10px 10px 10px; width: 100%; }
.comment-header { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-light); margin-bottom: 5px; }

.comment-input-wrapper { display: flex; gap: 10px; margin-top: 15px; }
.input-glass { flex: 1; padding: 10px 15px; border-radius: 50px; border: 1px solid var(--border-color); outline: none; }
.btn-send { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-color); color: white; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* --- COMMENT ACTIONS --- */
.comment-actions { display: flex; gap: 12px; opacity: 0; transition: opacity 0.2s ease-in-out; }
.comment-bubble:hover .comment-actions { opacity: 1; }
.btn-comment-action { background: transparent; border: none; padding: 0; font-size: 0.75rem; font-weight: 600; color: var(--text-light); cursor: pointer; transition: all 0.2s ease; }
.btn-comment-action:hover { color: var(--primary-color); text-decoration: underline; }
.btn-comment-action.delete:hover { color: #ef4444; text-decoration: underline; }

/* --- RESPONSIVE MEDIA QUERIES --- */

/* Toggle Button (Default Hidden) */
#menu-toggle, #sidebar-close {
    display: none;
    background: transparent; border: none; font-size: 1.5rem; color: var(--text-dark); cursor: pointer;
}
/* TABLET & MOBILE (< 992px) */
@media (max-width: 992px) {
    /* Sidebar: Hidden by default, slides in from left */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        /* Ensure it's on top of the overlay */
        z-index: 1050; 
        top: 0; left: 0; bottom: 0;
        height: 100vh;
        position: fixed;
    }
    
    /* Active Class to Show Sidebar */
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 5px 0 25px rgba(0,0,0,0.2);
    }

    /* Main Content: Expands to full width always on mobile */
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 20px;
    }

    /* Header: Show Menu Button */
    #menu-toggle { 
        display: flex; 
        align-items: center; 
        justify-content: center;
        margin-right: 15px;
        z-index: 100; /* Ensure button is clickable */
    }
    
    /* Sidebar Close Button (Inside Sidebar) */
    #sidebar-close {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 15px; 
        right: 15px;
        color: var(--text-medium);
        background: transparent;
        border: none;
        font-size: 1.2rem;
        cursor: pointer;
        z-index: 1060;
        width: 30px; height: 30px;
    }
    
    /* Adjust brand position for close button */
    .sidebar .brand {
        margin-right: 30px; 
    }
}

/* MOBILE (< 768px) */
@media (max-width: 768px) {
    /* Header Area */
    .header-area {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        text-align: center;
    }
    .header-title-row {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        position: relative;
    }
    /* Position menu button absolutely to the left on mobile header */
    #menu-toggle { position: absolute; left: 0; margin: 0; }

    /* Search Bar & Buttons */
    .search-form { width: 100%; }
    .btn-primary-custom { width: 100%; }

    /* Ticket Rows */
    .ticket-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .ticket-info-left {
        width: 100%;
        margin-bottom: 10px;
    }
    .ticket-title h4 { white-space: normal; /* Allow wrapping */ }
    
    .ticket-meta-right {
        width: 100%;
        justify-content: space-between;
        border-top: 1px dashed var(--border-color);
        padding-top: 10px;
    }
    
    /* Hide "Started" date on very small screens to save space, keep Due Date */
    .date-group:first-child { display: none; }

    /* Stat Cards (Reports Page) */
    .stat-card { flex-direction: column; text-align: center; }
    
    /* Calendar Toolbar */
    .fc-toolbar { flex-direction: column; gap: 10px; }
    .fc-toolbar-title { font-size: 1.2rem !important; }
}

/* AUTH PAGES */
.auth-container { width: 100%; max-width: 400px; margin: 0 auto; padding: 20px; }
.auth-card { padding: 30px; border-radius: 16px; background: white; box-shadow: var(--shadow-lg); }