/* style.css */

:root {
    --primary-gradient: linear-gradient(45deg, #4CAF50, #8BC34A); /* Fresh green gradient */
    --text-dark: #37474F; /* Dark grey */
    --text-muted: #78909C; /* Muted grey */
    --card-bg: #FFFFFF;
    --background-light: #F5F7FA; /* Very subtle light blue-grey background */
    --border-color: #ECEFF1; /* Very light grey border */
    --input-focus-border: #4CAF50; /* Green focus */
    --input-focus-shadow: rgba(76, 175, 80, 0.1);
    --button-text-color: #FFFFFF;

    /* Specific button colors for consistency */
    --btn-user-bg: #4CAF50; /* Green */
    --btn-user-hover-bg: #43A047;
    --btn-officer-bg: #2196F3; /* Blue */
    --btn-officer-hover-bg: #1976D2;
    --btn-admin-bg: #9C27B0; /* Purple */
    --btn-admin-hover-bg: #7B1FA2;
    --btn-generic-bg: #37474F; /* Dark grey */
    --btn-generic-hover-bg: #263238;

    /* Demo Role Button Colors (on hover) */
    --demo-user-color: #4CAF50; /* Green */
    --demo-officer-color: #2196F3; /* Blue */
    --demo-admin-color: #9C27B0; /* Purple */

    /* Narrative Half Colors */
    --narrative-bg-gradient: linear-gradient(135deg, #3F51B5 0%, #2196F3 100%); /* Blue gradient for narrative side */
    --narrative-text-color: #FFFFFF;
    --narrative-overlay-color: rgba(255, 255, 255, 0.05);

    /* Sidebar Variables */
    --sidebar-width-expanded: 250px;
    --sidebar-width-collapsed: 80px;
    --sidebar-bg: #34495E; /* Dark blue-grey for sidebar */
    --sidebar-text-color: #ECF0F1; /* Light text */
    --sidebar-hover-bg: #4A6572; /* Slightly lighter dark */
    --sidebar-active-color: var(--primary-gradient); /* Active item background */
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    overflow: hidden;
}

/* Main container for the split layout */
.main-container {
    display: flex;
    width: 100%;
    height: 100vh; /* Full viewport height */
}

/* Image/Narrative Half (for login page) */
.image-half {
    flex: 1;
    background: var(--narrative-bg-gradient);
    color: var(--narrative-text-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    border-top-right-radius: 2rem; /* Consistent with previous app-card radius */
    border-bottom-right-radius: 2rem;
    box-shadow: 0 0.75rem 2.5rem rgba(0, 0, 0, 0.1);
}

.image-half::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: var(--narrative-overlay-color); /* Subtle light overlay */
    transform: rotate(45deg);
    animation: rotateBackground 20s linear infinite;
}
@keyframes rotateBackground {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.narrative-content {
    position: relative;
    z-index: 1;
    max-width: 500px;
    animation: slideInLeft 0.8s ease-out forwards;
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-50px); }
    to { opacity: 1; transform: translateX(0); }
}
.narrative-content h2 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    line-height: 1.2;
    text-shadow: 0 3px 6px rgba(0,0,0,0.2);
    color: var(--narrative-text-color); /* Ensure text color is white */
}
.narrative-content p {
    font-size: 1.25rem;
    font-weight: 300;
    opacity: 0.9;
    line-height: 1.6;
    color: var(--narrative-text-color); /* Ensure text color is white */
}


/* Login Half (for login page) */
.login-half {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--background-light); /* Use light background for this half */
    padding: 2.5rem;
}

/* Base card styling for all pages */
.app-card {
    background-color: var(--card-bg);
    border-radius: 1.25rem;
    box-shadow: 0 0.75rem 2.5rem rgba(0, 0, 0, 0.06);
    padding: 3.5rem;
    width: 100%;
    max-width: 450px; /* Default max-width for login/add screens */
    text-align: center;
    animation: fadeIn 0.7s ease-out;
}

/* Specific max-width for dashboards */
.user-dashboard-card, .officer-dashboard-card {
    max-width: 800px;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 4rem); /* Take full height of content-area, minus padding */
    box-sizing: border-box; /* Include padding in height calculation */
    /* Add overflow-y: hidden to prevent card itself from scrolling */
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 15px;
}

.admin-dashboard-card {
    max-width: 900px;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 4rem); /* Take full height of content-area, minus padding */
    box-sizing: border-box; /* Include padding in height calculation */
    overflow-y: hidden;
}


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

h1, h2, h3 {
    color: var(--text-dark);
    font-weight: 700;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}
h2 {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}
h3 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

p.tagline, .text-muted {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
}

.form-control {
    border-radius: 0.6rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    font-size: 1rem;
}
.form-control:focus {
    border-color: var(--input-focus-border);
    box-shadow: 0 0 0 0.2rem var(--input-focus-shadow);
    background-color: #FAFAFA; /* Slight background on focus */
}

.btn {
    border-radius: 0.6rem;
    padding: 1rem 1.5rem;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--button-text-color);
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border: none; /* Remove default Bootstrap button border */
}
.btn:hover {
    /* Enhanced hover effect for better visibility */
    opacity: 0.9;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2); /* More prominent shadow */
    transform: translateY(-3px); /* Increased vertical lift */
}

/* Specific button styles */
.btn-primary-gradient {
    background: var(--primary-gradient);
}

.btn-user {
    background-color: var(--btn-user-bg);
}
.btn-user:hover {
    background-color: var(--btn-user-hover-bg);
}

.btn-officer {
    background-color: var(--btn-officer-bg);
}
.btn-officer:hover {
    background-color: var(--btn-officer-hover-bg);
}

.btn-admin {
    background-color: var(--btn-admin-bg);
}
.btn-admin:hover {
    background-color: var(--btn-admin-hover-bg);
}

.btn-generic {
    background-color: var(--btn-generic-bg);
}
.btn-generic:hover {
    background-color: var(--btn-generic-hover-bg);
}

.btn-outline-custom {
    border: 1px solid var(--border-color);
    color: var(--text-dark);
    background-color: transparent;
}
.btn-outline-custom:hover {
    background-color: #F0F0F0;
    border-color: #D0D0D0;
}

/* Demo Role Buttons (default gray, colored on hover) */
.btn-demo-role {
    background-color: #E0E0E0; /* Default light gray */
    color: var(--text-dark); /* Dark text on gray */
    border: 1px solid #D0D0D0;
}

#login-as-user-btn.btn-demo-role:hover {
    background-color: var(--demo-user-color);
    color: var(--button-text-color);
    border-color: var(--demo-user-color);
}

#login-as-officer-btn.btn-demo-role:hover {
    background-color: var(--demo-officer-color);
    color: var(--button-text-color);
    border-color: var(--demo-officer-color);
}

#login-as-admin-btn.btn-demo-role:hover {
    background-color: var(--demo-admin-color);
    color: var(--button-text-color);
    border-color: var(--demo-admin-color);
}


.text-link {
    color: #4CAF50; /* Green link */
    text-decoration: none;
    font-weight: 500;
}
.text-link:hover {
    text-decoration: underline;
}

.divider {
    margin: 2.5rem 0;
    position: relative;
    text-align: center;
}
.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: var(--border-color);
    z-index: 0;
}
.divider span {
    background-color: var(--card-bg);
    padding: 0 1rem;
    position: relative;
    z-index: 1;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Alerts */
.alert {
    border-radius: 0.6rem;
    font-weight: 500;
    font-size: 1rem;
}

/* License List Specific Styles (for user dashboard) */
.licenses-list-container { /* New container for licenses list with scroll */
    flex-grow: 1; /* Allow it to take available vertical space */
    overflow-y: auto; /* Enable vertical scrolling */
    padding-right: 15px; /* Add padding for scrollbar */
    /* Crucial: Set a max-height relative to the parent's *actual* content area */
    max-height: calc(100% - 150px); /* Adjust this value as needed based on header/footer height */
    /* This calculation needs to be precise based on the fixed height elements above and below it in the parent flex container */
    /* For user-dashboard-card: h1, message-container, dashboard-header, category-buttons, insights-loading/output, logout-btn */
    /* Let's try to make it take up remaining space and then scroll */
}

.license-item {
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 0.75rem;
    background-color: var(--card-bg);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.license-item.deleted {
    background-color: #F0F0F0;
    color: var(--text-muted);
    text-decoration: line-through;
    opacity: 0.7;
}
.license-item.expired {
    border-color: #FFC107; /* Amber border for expired */
    background-color: #FFFDE7; /* Very light yellow background */
}
.license-item h5 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-dark);
}
.license-item p {
    font-size: 0.9rem;
    margin-bottom: 0.1rem;
    color: var(--text-muted);
}
.license-item .badge {
    font-size: 0.75rem;
    padding: 0.4em 0.7em;
    border-radius: 0.3rem;
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
}

/* View QR button: Always visible, styled to fit theme */
.view-qr-btn {
    background-color: #F0F0F0; /* Light gray background */
    color: var(--text-dark); /* Dark text */
    border: 1px solid #D0D0D0; /* Light gray border */
    border-radius: 0.6rem;
    padding: 0.5rem 1rem; /* Adjust padding for sm button */
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); /* Subtle shadow */
}
.view-qr-btn:hover {
    background: var(--primary-gradient); /* Gradient on hover */
    color: var(--button-text-color);
    border-color: transparent; /* Remove border on hover */
    box-shadow: 0 4px 10px rgba(0,0,0,0.1); /* More prominent shadow on hover */
    transform: translateY(-1px); /* Slight lift on hover */
}


/* Dashboard specific elements */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Main Dashboard Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    background-color: var(--background-light); /* Ensure background for content area */
    overflow-x: hidden; /* Prevent horizontal scroll from transitions */
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width-expanded);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text-color);
    padding: 1.5rem 1rem;
    box-shadow: 0.25rem 0 1rem rgba(0, 0, 0, 0.1);
    transition: width 0.3s ease, padding 0.3s ease;
    flex-shrink: 0; /* Prevent shrinking */
    display: flex;
    flex-direction: column;
    position: fixed; /* Fixed position for sidebar */
    height: 100vh; /* Full height */
    z-index: 1000; /* Ensure it's on top */
}

.sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
    padding: 1.5rem 0.5rem;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.sidebar-header h3 {
    color: var(--sidebar-text-color);
    font-size: 1.5rem;
    font-weight: 700;
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden; /* Hide overflow when collapsed */
    text-overflow: ellipsis; /* Add ellipsis for overflow */
}

.sidebar-header .hamburger-icon {
    background: none;
    border: none;
    color: var(--sidebar-text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.3s ease;
}
.sidebar-header .hamburger-icon:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1; /* Allow menu to take available space */
}

.sidebar-menu-item {
    margin-bottom: 0.5rem;
}

.sidebar-menu-item a {
    display: flex;
    align-items: center;
    padding: 0.8rem 1rem;
    color: var(--sidebar-text-color);
    text-decoration: none;
    border-radius: 0.6rem;
    transition: background-color 0.3s ease, color 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-menu-item a:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-text-color);
}
.sidebar-menu-item a.active {
    background: var(--sidebar-active-color); /* Gradient for active item */
    color: var(--button-text-color);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.sidebar-menu-item a.active:hover {
    opacity: 0.9;
    box-shadow: 0 6px 15px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}


.sidebar-menu-item i {
    font-size: 1.25rem;
    margin-right: 1rem;
    width: 24px; /* Fixed width for icons to prevent text shifting */
    text-align: center;
}

.sidebar.collapsed .sidebar-menu-item a {
    justify-content: center; /* Center icons when collapsed */
    padding: 0.8rem 0.5rem;
}
.sidebar.collapsed .sidebar-menu-item a span {
    display: none; /* Hide text when collapsed */
}
.sidebar.collapsed .sidebar-header h3 {
    display: none; /* Hide title when collapsed */
}

/* Content Area Styling */
.content-area {
    flex-grow: 1;
    margin-left: var(--sidebar-width-expanded); /* Initial margin for expanded sidebar */
    padding: 2rem;
    transition: margin-left 0.3s ease;
    display: flex;
    justify-content: center; /* Center content horizontally */
    align-items: flex-start; /* Align content to top */
    min-height: 100vh; /* Ensure content area takes full height */
    overflow-y: auto; /* Enable vertical scrolling for content */
}

.content-area.shifted {
    margin-left: var(--sidebar-width-collapsed);
}

/* Removed specific styles for collapsing content as it's no longer used */
/* .license-details-collapse, .license-details-collapse.show-details */

.license-header-clickable {
    /* No longer clickable for collapse, but keep for layout if needed */
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
/* Removed .license-item .btn-sm as icon-btn has its own styling */
.license-item .d-flex.flex-column {
    flex-shrink: 0; /* Prevent buttons from shrinking */
}

/* Category buttons styling */
.category-buttons .btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
    background-color: #E0E0E0; /* Default gray from demo-role-btn */
    color: var(--text-dark);
    border: 1px solid #D0D0D0;
    transition: all 0.3s ease;
}
.category-buttons .btn.active-category {
    background: var(--primary-gradient);
    color: var(--button-text-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-color: transparent;
}
.category-buttons .btn:hover:not(.active-category) {
    background-color: #D0D0D0;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}


/* Responsive adjustments */
@media (max-width: 768px) {
    /* General adjustments from previous versions */
    body {
        padding: 0;
    }
    .main-container {
        flex-direction: column;
        height: auto;
    }
    .image-half {
        height: 300px;
        border-radius: 0;
        box-shadow: none;
        padding: 2rem;
    }
    .narrative-content h2 {
        font-size: 2.5rem;
    }
    .narrative-content p {
        font-size: 1rem;
    }
    .login-half {
        padding: 1.5rem;
    }
    .app-card {
        padding: 2rem;
        border-radius: 0;
        box-shadow: none;
        max-width: 100%;
    }
    h1 {
        font-size: 2rem;
    }
    h2 {
        font-size: 1.6rem;
    }
    h3 {
        font-size: 1.3rem;
    }
    .form-control {
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }
    .btn {
        padding: 0.8rem 1rem;
        font-size: 1rem;
    }
    .dashboard-grid-buttons .btn {
        padding: 0.7rem 0.8rem;
        font-size: 0.9rem;
    }
    .license-item {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
    }
    .license-item .btn {
        margin-top: 0.75rem;
        align-self: flex-end;
    }

    /* Sidebar specific adjustments for mobile */
    .sidebar {
        position: fixed; /* Keep fixed for mobile overlay */
        width: 100%; /* Full width when open on mobile */
        height: 100%;
        left: -100%; /* Start off-screen */
        top: 0;
        padding: 1.5rem;
        box-shadow: 0.5rem 0 1.5rem rgba(0, 0, 0, 0.2);
        transition: left 0.3s ease;
    }
    .sidebar.open-mobile {
        left: 0; /* Slide in from left */
    }
    .sidebar.collapsed { /* No collapsed state on mobile, it's either open or hidden */
        width: 100%;
        padding: 1.5rem;
    }
    .sidebar.collapsed .sidebar-menu-item a span,
    .sidebar.collapsed .sidebar-header h3 {
        display: block; /* Show text on mobile even if 'collapsed' class is present */
    }
    .sidebar.collapsed .sidebar-menu-item a {
        justify-content: flex-start; /* Align left */
        padding: 0.8rem 1rem;
    }

    .content-area {
        margin-left: 0; /* No margin on mobile */
        padding: 1rem;
    }
    /* Hamburger icon always visible on mobile */
    .hamburger-icon-mobile {
        display: block;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 1001; /* Above sidebar */
        background-color: var(--sidebar-bg);
        color: var(--sidebar-text-color);
        padding: 0.5rem 0.75rem;
        border-radius: 0.5rem;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        cursor: pointer;
    }

    /* Category buttons on mobile */
    .category-buttons {
        justify-content: flex-start; /* Align categories left on mobile */
        overflow-x: auto; /* Enable horizontal scrolling for categories */
        flex-wrap: nowrap; /* Prevent wrapping */
        padding-bottom: 0.5rem; /* Give space for scrollbar */
    }
    .category-buttons .btn {
        flex-shrink: 0; /* Prevent buttons from shrinking too much */
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }
}

/* Fix for outline buttons showing white-on-white */
.btn-outline-primary {
    color: #0d6efd;
    border-color: #0d6efd;
}

.btn-outline-primary:hover {
    background-color: #0d6efd;
    color: #fff;
}

.btn-outline-danger {
    color: #dc3545;
    border-color: #dc3545;
}

.btn-outline-danger:hover {
    background-color: #dc3545;
    color: #fff;
}
