/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette */
    --primary-blue: #2563eb;
    --dark-blue: #1e40af;
    --light-blue: #3b82f6;
    --primary-black: #1a1a1a;
    --secondary-black: #2d2d2d;
    --primary-grey: #6b7280;
    --light-grey: #9ca3af;
    --lighter-grey: #e5e7eb;
    --lightest-grey: #f3f4f6;
    --white: #ffffff;
    
    /* Spacing */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --header-height: 70px;
    
    /* Transitions */
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--lightest-grey);
    color: var(--primary-black);
    line-height: 1.6;
    overflow-x: hidden;
    max-width: 100vw;
    /* Safe area support for mobile devices with notches */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Login Page Styles */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-black) 0%, var(--secondary-black) 50%, var(--dark-blue) 100%);
    /* Safe area support for login page */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.login-container {
    width: 100%;
    max-width: 440px;
    padding: 20px;
}

.login-box {
    background: var(--white);
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-header svg {
    color: var(--primary-blue);
    margin-bottom: 20px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-black);
    margin-bottom: 8px;
}

.login-header p {
    font-size: 14px;
    color: var(--primary-grey);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-black);
}

.form-group input {
    padding: 12px 16px;
    border: 2px solid var(--lighter-grey);
    border-radius: 8px;
    font-size: 14px;
    transition: var(--transition);
    background: var(--white);
    color: var(--primary-black);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-blue);
}

.error-message {
    padding: 12px;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    font-size: 14px;
}

.btn-login {
    padding: 14px;
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-login:hover {
    background: var(--dark-blue);
    transform: translateY(-1px);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-loader svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
    /* Prevent overscroll bounce on iOS */
    position: relative;
    -webkit-overflow-scrolling: touch;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    color: var(--primary-black);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transition: var(--transition);
    border-right: 1px solid var(--lighter-grey);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
    /* Safe area support */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.sidebar-header {
    padding: 24px 16px;
    border-bottom: 1px solid var(--lighter-grey);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-black);
    white-space: nowrap;
    overflow: hidden;
    transition: var(--transition);
    flex: 1;
    min-width: 0;
}

.sidebar-collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--primary-grey);
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    background: var(--lightest-grey);
    color: var(--primary-blue);
}

.sidebar-collapse-btn svg {
    transition: transform 0.3s ease;
}

.sidebar.collapsed .sidebar-collapse-btn svg {
    transform: rotate(180deg);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    gap: 4px;
}

.menu-toggle span {
    width: 24px;
    height: 2px;
    background: var(--primary-black);
    transition: var(--transition);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin-bottom: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--primary-grey);
    text-decoration: none;
    transition: var(--transition);
    position: relative;
    border-radius: 8px;
    margin: 0 12px;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 0;
    background: var(--primary-blue);
    transition: var(--transition);
    border-radius: 0 4px 4px 0;
}

.nav-item:hover {
    background: var(--lightest-grey);
    color: var(--primary-black);
}

.nav-item.active {
    color: var(--primary-blue);
    background: rgba(37, 99, 235, 0.1);
    font-weight: 600;
}

.nav-item.active::before {
    height: 100%;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--lighter-grey);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 20px;
    background: transparent;
    border: 1px solid var(--lighter-grey);
    border-radius: 8px;
    color: var(--primary-grey);
    cursor: pointer;
    transition: var(--transition);
}

.logout-btn:hover {
    background: #fef2f2;
    border-color: #dc2626;
    color: #dc2626;
}

/* Collapsed Sidebar Styles */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-header h2 {
    opacity: 0;
    width: 0;
}

.sidebar.collapsed .nav-item span,
.sidebar.collapsed .logout-btn span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 14px;
    margin: 0 8px;
}

.sidebar.collapsed .nav-item::before {
    display: none;
}

.sidebar.collapsed .logout-btn {
    justify-content: center;
    padding: 14px;
}

.sidebar.collapsed .sidebar-footer {
    padding: 12px 8px;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 24px 8px;
}

/* Adjust main content when sidebar is collapsed */
.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Tooltip for collapsed nav items */
.sidebar.collapsed .nav-item {
    position: relative;
}

.sidebar.collapsed .nav-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary-black);
    color: var(--white);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    pointer-events: none;
    z-index: 1001;
}

.sidebar.collapsed .nav-item::after {
    content: attr(data-page);
}

.sidebar.collapsed .nav-item:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    max-width: calc(100vw - var(--sidebar-width));
    overflow: hidden;
}

.top-header {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--lighter-grey);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    max-width: 100%;
    box-sizing: border-box;
    /* Safe area support */
    padding-left: max(32px, env(safe-area-inset-left));
    padding-right: max(32px, env(safe-area-inset-right));
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    flex-direction: column;
    gap: 4px;
}

.mobile-menu-btn span {
    width: 24px;
    height: 2px;
    background: var(--primary-black);
    transition: var(--transition);
}

.header-user-wrapper {
    position: relative;
    margin-left: auto;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--lightest-grey);
    border: none;
    border-radius: 8px;
    transition: var(--transition);
    cursor: pointer;
    font-family: inherit;
}

.header-user:hover {
    background: var(--lighter-grey);
}

.header-user svg:first-child {
    color: var(--primary-blue);
    flex-shrink: 0;
}

.header-user .chevron-icon {
    color: var(--primary-grey);
    transition: transform 0.3s ease;
}

.header-user.active .chevron-icon {
    transform: rotate(180deg);
}

.header-user span {
    font-size: 14px;
    color: var(--primary-black);
    font-weight: 500;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--white);
    border: 1px solid var(--lighter-grey);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    color: var(--primary-black);
    transition: var(--transition);
    text-align: left;
}

.dropdown-item:hover {
    background: var(--lightest-grey);
}

.dropdown-item.logout-item {
    color: #dc2626;
}

.dropdown-item.logout-item:hover {
    background: #fef2f2;
}

.dropdown-item svg {
    color: currentColor;
    flex-shrink: 0;
}

/* Content Area */
.content-area {
    padding: 32px;
    flex: 1;
    overflow: hidden;
    max-width: 100%;
}

.page-content {
    display: none;
    max-width: 100%;
    overflow: hidden;
}

.page-content.active {
    display: block;
    max-width: 100%;
    overflow: hidden;
}

.page-content h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-black);
    margin-bottom: 32px;
    max-width: 100%;
    overflow-wrap: break-word;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    max-width: 100%;
    box-sizing: border-box;
}

.page-header h1 {
    margin-bottom: 0;
}

.page-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

/* Buttons */
.btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--dark-blue);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.dashboard-card {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
}

.dashboard-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.card-icon {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-icon.blue {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-blue);
}

.card-icon.grey {
    background: rgba(107, 114, 128, 0.1);
    color: var(--primary-grey);
}

.card-info h3 {
    font-size: 14px;
    color: var(--primary-grey);
    font-weight: 500;
    margin-bottom: 8px;
}

.card-number {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-black);
}

/* Chart Section */
.chart-section {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 40px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.chart-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-black);
    margin: 0;
}

.chart-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.chart-control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-control-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-grey);
    white-space: nowrap;
}

.chart-period-select,
.chart-month-picker {
    padding: 8px 16px;
    border: 2px solid var(--lighter-grey);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    background: var(--white);
    color: var(--primary-black);
    cursor: pointer;
    transition: var(--transition);
    box-sizing: border-box;
    min-width: 0;
}

.chart-month-picker {
    min-width: 0 !important;
    max-width: 100% !important;
}

.chart-period-select:hover,
.chart-month-picker:hover {
    border-color: var(--primary-blue);
}

.chart-period-select:focus,
.chart-month-picker:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chart-period-select {
    min-width: 180px;
}

.chart-container-wrapper {
    position: relative;
    height: 350px;
    width: 100%;
}

.chart-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.chart-empty-state svg {
    color: var(--light-grey);
    margin-bottom: 16px;
}

.chart-empty-state p {
    color: var(--primary-grey);
    font-size: 15px;
}

/* Recent Activity */
.recent-activity {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.recent-activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.recent-activity-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-black);
    margin: 0;
}

.recent-activity h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-black);
    margin-bottom: 20px;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.empty-state {
    text-align: center;
    color: var(--primary-grey);
    padding: 40px;
    font-size: 14px;
}

/* Filter Section */
.filter-section {
    background: var(--white);
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.filter-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--white);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-size: 15px;
    font-weight: 600;
    color: var(--primary-black);
}

.filter-toggle:hover {
    background: var(--lightest-grey);
}

.filter-toggle .filter-icon {
    color: var(--primary-blue);
}

.filter-toggle span {
    flex: 1;
    text-align: left;
}

.filter-toggle .chevron-icon {
    color: var(--primary-grey);
    transition: transform 0.3s ease;
}

.filter-section.expanded .filter-toggle .chevron-icon {
    transform: rotate(180deg);
}

.filter-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.filter-section.expanded .filter-content {
    max-height: 500px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    padding: 20px;
    border-top: 1px solid var(--lighter-grey);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-black);
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--lighter-grey);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: var(--white);
    color: var(--primary-black);
    box-sizing: border-box;
    min-width: 0;
}

/* Specific styling for date inputs in filters */
.filter-group input[type="date"],
.filter-group input[type="time"],
.filter-group input[type="month"] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    display: block;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--primary-blue);
}

.filter-group input::placeholder {
    color: var(--light-grey);
}

.filter-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 16px 20px;
    border-top: 1px solid var(--lighter-grey);
}

/* Reservations List */
.reservations-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 100%;
    overflow: hidden;
}

/* Vehicles List */
.vehicles-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Modal Styles */
.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;
    padding: 20px;
    overflow-y: auto;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--lighter-grey);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-black);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary-grey);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--lightest-grey);
    color: var(--primary-black);
}

.modal-form {
    padding: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
    overflow: hidden;
}

.form-row .form-group {
    min-width: 0;
    overflow: hidden;
}

.form-row .form-group input,
.form-row .form-group select {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
}

.modal-form .form-group {
    margin-bottom: 16px;
}

.modal-form .form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-black);
    margin-bottom: 8px;
}

.modal-form .form-group input,
.modal-form .form-group select,
.modal-form .form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--lighter-grey);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: var(--white);
    color: var(--primary-black);
    box-sizing: border-box;
    min-width: 0;
}

/* Specific styling for date and time inputs to match other inputs */
.modal-form .form-group input[type="date"],
.modal-form .form-group input[type="time"],
.modal-form .form-group input[type="month"] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    display: block;
    flex: 1 1 auto;
}

.modal-form .form-group input:focus,
.modal-form .form-group select:focus,
.modal-form .form-group textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
}

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

.form-error {
    padding: 12px;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    font-size: 14px;
    margin-bottom: 16px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 16px 0;
    border-top: 1px solid var(--lighter-grey);
}

.btn-secondary {
    padding: 12px 24px;
    background: var(--white);
    color: var(--primary-grey);
    border: 2px solid var(--lighter-grey);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--lightest-grey);
    color: var(--primary-black);
    border-color: var(--light-grey);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 8px;
    background: var(--white);
    border: 1px solid var(--lighter-grey);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--primary-grey);
}

.btn-icon:hover {
    background: var(--lightest-grey);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.btn-icon.delete-vehicle-btn:hover {
    border-color: #dc2626;
    color: #dc2626;
    background: #fef2f2;
}

/* Data Table */
.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--dark-blue) 100%);
    color: var(--white);
    border-radius: 12px 12px 0 0;
    margin-bottom: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.toolbar-info {
    font-size: 14px;
    font-weight: 600;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.table-container {
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 340px);
    overflow-x: auto;
    overflow-y: auto;
    background: var(--white);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    box-sizing: border-box;
}

.table-toolbar + .table-container {
    border-radius: 0;
    box-shadow: none;
    border: 1px solid var(--lighter-grey);
    border-top: none;
    border-bottom: none;
    max-height: calc(100vh - 390px);
    max-width: 100%;
}

/* Custom scrollbar for table */
.table-container::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.table-container::-webkit-scrollbar-track {
    background: var(--lightest-grey);
    border-radius: 8px;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--light-grey);
    border-radius: 8px;
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-grey);
}

.table-container::-webkit-scrollbar-corner {
    background: var(--lightest-grey);
}

.data-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.data-table thead {
    background: linear-gradient(to bottom, #f9fafb, var(--lightest-grey));
}

.data-table th {
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--primary-black);
    border-bottom: 2px solid var(--lighter-grey);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: linear-gradient(to bottom, #f9fafb, var(--lightest-grey));
    z-index: 10;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.05);
}

.data-table th.checkbox-column {
    position: sticky;
    left: 0;
    z-index: 20;
    background: var(--lightest-grey);
}

.data-table td.checkbox-column {
    position: sticky;
    left: 0;
    z-index: 5;
    background: inherit;
}

.data-table td {
    padding: 16px 12px;
    border-bottom: 1px solid #f0f0f0;
    color: var(--primary-black);
}

.data-table tbody tr {
    transition: var(--transition);
    background: var(--white);
}

.data-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.data-table tbody tr:hover {
    background: #f0f7ff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.checkbox-column {
    width: 50px;
    text-align: center;
    padding: 12px 16px !important;
}

.table-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-blue);
}

.table-checkbox:hover {
    transform: scale(1.1);
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status-reserved {
    background: #dbeafe;
    color: #1e40af;
}

.status-changeable {
    background: #fef3c7;
    color: #92400e;
}

.action-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn-icon-small {
    width: 28px;
    height: 28px;
    padding: 6px;
    background: var(--white);
    border: 1px solid var(--lighter-grey);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--primary-grey);
}

.btn-icon-small:hover {
    background: var(--lightest-grey);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.btn-icon-small.delete-reservation-btn:hover {
    border-color: #dc2626;
    color: #dc2626;
    background: #fef2f2;
}

/* Pagination Styles */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--white);
    border-radius: 0 0 12px 12px;
    border: 1px solid var(--lighter-grey);
    border-top: none;
    gap: 16px;
    flex-wrap: wrap;
}

.pagination-info {
    font-size: 14px;
    color: var(--primary-grey);
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border: 1px solid var(--lighter-grey);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--primary-grey);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--lightest-grey);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-pages {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-page {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border: 1px solid var(--lighter-grey);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--primary-grey);
    font-size: 14px;
    font-weight: 500;
}

.pagination-page:hover {
    background: var(--lightest-grey);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

.pagination-page.active {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: var(--white);
    font-weight: 600;
}

.pagination-ellipsis {
    padding: 0 8px;
    color: var(--primary-grey);
    font-size: 14px;
}

.pagination-rows-per-page {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--primary-grey);
}

.pagination-rows-per-page label {
    font-weight: 500;
    white-space: nowrap;
}

.rows-per-page-select {
    padding: 6px 12px;
    border: 1px solid var(--lighter-grey);
    border-radius: 6px;
    background: var(--white);
    color: var(--primary-black);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.rows-per-page-select:hover {
    border-color: var(--primary-blue);
}

.rows-per-page-select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Confirmation Modal */
.confirm-modal-content {
    max-width: 440px;
    text-align: center;
    padding: 32px;
}

/* Conflict Modal */
.conflict-modal-content {
    max-width: 600px;
}

.conflict-modal-body {
    padding: 24px;
    padding-bottom: 16px;
}

.conflict-modal-content .modal-footer {
    padding: 16px 24px;
    margin: 0;
}

.conflict-warning-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fef3c7;
    color: #d97706;
}

.conflict-modal-body h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-black);
    margin-bottom: 16px;
    text-align: center;
}

.conflict-details {
    background: var(--lightest-grey);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.conflict-details p {
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--primary-grey);
}

.conflict-details p:last-child {
    margin-bottom: 0;
}

.conflict-details strong {
    color: var(--primary-black);
    font-weight: 600;
}

.conflict-list {
    margin-top: 12px;
}

.conflict-list ul {
    list-style: none;
    margin: 8px 0 0 0;
    padding: 0;
}

.conflict-list li {
    padding: 8px 12px;
    background: var(--white);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--primary-black);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conflict-driver {
    color: var(--primary-grey);
    font-size: 13px;
    margin-left: 8px;
}

.available-times-container {
    margin-top: 20px;
}

.available-times-container h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-black);
    margin-bottom: 12px;
}

.available-times-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.available-time-slot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 2px solid var(--lighter-grey);
    border-radius: 8px;
    transition: var(--transition);
    cursor: pointer;
}

.available-time-slot:hover {
    background: var(--lightest-grey);
    border-color: var(--primary-blue);
}

.available-time-slot input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-blue);
}

.available-time-slot input[type="radio"]:checked + label {
    color: var(--primary-blue);
}

.available-time-slot label {
    flex: 1;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
}

.available-time-slot label strong {
    font-weight: 600;
    color: var(--primary-black);
}

.available-time-slot .time-range {
    font-size: 13px;
    color: var(--primary-grey);
}

.no-slots {
    text-align: center;
    padding: 20px;
    color: var(--primary-grey);
    font-size: 14px;
}

/* Activities Modal */
.activities-modal-content {
    max-width: 800px;
    max-height: 90vh;
}

.activities-modal-body {
    padding: 24px;
    max-height: calc(90vh - 140px);
    overflow-y: auto;
}

.all-activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.activity-item {
    padding: 16px;
    background: var(--lightest-grey);
    border-radius: 8px;
    border-left: 4px solid var(--primary-blue);
    transition: var(--transition);
}

.activity-item:hover {
    background: #e8edf5;
    transform: translateX(2px);
}

.activity-item-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    color: var(--primary-blue);
}

.activity-item-content {
    flex: 1;
}

.activity-item-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary-black);
    margin-bottom: 4px;
}

.activity-item-description {
    font-size: 14px;
    color: var(--primary-grey);
}

.activity-item-time {
    font-size: 13px;
    color: var(--light-grey);
    margin-top: 8px;
}

/* Activity Filter Section */
.activity-filter-section {
    margin-bottom: 20px;
    border: 2px solid var(--lighter-grey);
    border-radius: 8px;
    overflow: hidden;
}

.activity-filter-toggle {
    width: 100%;
    padding: 12px 16px;
    background: var(--lightest-grey);
    border: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-black);
    cursor: pointer;
    transition: var(--transition);
}

.activity-filter-toggle:hover {
    background: #e8edf5;
}

.activity-filter-toggle .toggle-icon {
    margin-left: auto;
    transition: transform 0.3s ease;
}

.activity-filter-section.expanded .activity-filter-toggle .toggle-icon {
    transform: rotate(180deg);
}

.activity-filter-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: var(--white);
}

.activity-filter-section.expanded .activity-filter-content {
    max-height: 400px;
}

.activity-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    padding: 16px;
}

.activity-filter-input,
.activity-filter-select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--lighter-grey);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--white);
    transition: var(--transition);
    box-sizing: border-box;
    min-width: 0;
}

/* Specific styling for date inputs in activity filters */
.activity-filter-input[type="date"],
.activity-filter-input[type="time"],
.activity-filter-input[type="month"] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    display: block;
}

.activity-filter-input:focus,
.activity-filter-select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.activity-filter-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 0 16px 16px 16px;
}

.activity-filter-actions button {
    min-width: 100px;
}

.confirm-modal-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fef2f2;
    color: #dc2626;
}

.confirm-modal-content h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-black);
    margin-bottom: 12px;
}

.confirm-modal-content p {
    font-size: 15px;
    color: var(--primary-grey);
    line-height: 1.6;
    margin-bottom: 24px;
}

.confirm-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-modal-actions .btn-secondary,
.confirm-modal-actions .btn-danger {
    flex: 1;
    max-width: 160px;
}

.btn-danger {
    padding: 12px 24px;
    background: #dc2626;
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-danger:active {
    transform: translateY(0);
}

.btn-danger:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-danger.btn-small {
    padding: 8px 16px;
    font-size: 13px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 220px;
    }
    
    .content-area {
        padding: 24px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        left: env(safe-area-inset-left);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        width: var(--sidebar-width);
    }
    
    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }
    
    .main-content {
        margin-left: 0;
        max-width: 100vw;
    }
    
    .mobile-menu-btn {
        display: flex;
        /* Ensure proper touch target size */
        min-width: 44px;
        min-height: 44px;
        padding: 12px;
    }
    
    .sidebar-collapse-btn {
        display: none;
    }
    
    .top-header {
        padding: 0 16px;
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
        padding-top: env(safe-area-inset-top);
    }
    
    .header-user {
        padding: 8px 12px;
        gap: 8px;
        /* Ensure proper touch target size */
        min-height: 44px;
    }
    
    .header-user span {
        font-size: 13px;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .user-dropdown {
        min-width: 180px;
        right: max(0px, env(safe-area-inset-right));
    }
    
    .dropdown-item {
        /* Improve touch targets on mobile */
        min-height: 48px;
        padding: 14px 16px;
    }
    
    .content-area {
        padding: 16px;
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
    
    .page-content h1 {
        font-size: 24px;
        margin-bottom: 24px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .chart-controls {
        width: 100%;
        flex-direction: column;
        gap: 12px;
    }
    
    .chart-control-group {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    
    .chart-period-select,
    .chart-month-picker {
        width: 100%;
    }
    
    .chart-container-wrapper {
        height: 300px;
    }
    
    .login-box {
        padding: 32px 24px;
    }
    
    /* Prevent zoom on input focus on iOS */
    input, select, textarea {
        font-size: 16px !important;
    }
    
    /* Better input spacing */
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 14px 16px;
        font-size: 16px;
    }
    
    /* Ensure date/time inputs match other inputs on mobile */
    input[type="date"],
    input[type="time"],
    input[type="month"] {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        font-size: 16px !important;
    }
}

@media (max-width: 480px) {
    .dashboard-card {
        flex-direction: column;
        text-align: center;
    }
    
    .card-icon {
        width: 56px;
        height: 56px;
    }
    
    .card-number {
        font-size: 28px;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
        justify-content: center;
        /* Ensure proper touch target */
        min-height: 48px;
        padding: 14px 20px;
    }
    
    .page-header-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .page-header-actions button {
        width: 100%;
        justify-content: center;
    }
    
    .login-box {
        padding: 24px;
    }
    
    .login-header h1 {
        font-size: 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        max-height: 90vh;
        margin: 5vh 16px;
        margin-bottom: max(5vh, env(safe-area-inset-bottom));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix modal positioning on mobile */
    .modal {
        padding: 0;
        align-items: flex-start;
        padding-top: max(20px, env(safe-area-inset-top));
    }
    
    .modal-header {
        padding: 20px;
        padding-top: max(20px, env(safe-area-inset-top));
    }
    
    .modal-form {
        padding: 20px;
    }
    
    .btn-icon {
        width: 44px;
        height: 44px;
        padding: 10px;
    }
    
    /* Improve touch targets for navigation */
    .nav-item {
        min-height: 48px;
        padding: 16px 20px;
    }
    
    /* Better logout button sizing */
    .logout-btn {
        min-height: 48px;
        padding: 16px 20px;
    }
    
    /* Better touch feedback */
    button, .nav-item, .reservation-card, .vehicle-card, .activity-item {
        -webkit-tap-highlight-color: rgba(37, 99, 235, 0.1);
    }
    
    /* Prevent text selection on double tap */
    .nav-item, button, .dashboard-card {
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Better reservation card spacing */
    .reservation-card {
        padding: 20px;
    }
    
    /* Better vehicle card spacing */
    .vehicle-card {
        padding: 20px;
    }
    
    .confirm-modal-content {
        padding: 24px;
    }
    
    .confirm-modal-icon {
        width: 64px;
        height: 64px;
    }
    
    .confirm-modal-icon svg {
        width: 40px;
        height: 40px;
    }
    
    .confirm-modal-content h2 {
        font-size: 20px;
    }
    
    .confirm-modal-content p {
        font-size: 14px;
    }
    
    .confirm-modal-actions {
        flex-direction: column-reverse;
    }
    
    .confirm-modal-actions .btn-secondary,
    .confirm-modal-actions .btn-danger {
        max-width: 100%;
        width: 100%;
    }
    
    .filter-grid {
        grid-template-columns: 1fr;
        padding: 16px;
    }
    
    .filter-actions {
        flex-direction: column;
        padding: 12px 16px;
    }
    
    .filter-actions button {
        width: 100%;
        justify-content: center;
    }
    
    .filter-section.expanded .filter-content {
        max-height: 800px;
    }
    
    .table-container {
        border-radius: 8px 8px 0 0;
        max-height: calc(100vh - 300px);
    }
    
    .table-toolbar + .table-container {
        max-height: calc(100vh - 370px);
    }
    
    .data-table {
        font-size: 13px;
    }
    
    .data-table th,
    .data-table td {
        padding: 10px 8px;
    }
    
    .table-toolbar {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .toolbar-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .toolbar-actions button {
        width: 100%;
        justify-content: center;
    }
    
    .checkbox-column {
        width: 40px;
        padding: 8px 8px !important;
    }
    
    .table-checkbox {
        width: 16px;
        height: 16px;
    }
    
    .pagination-container {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }
    
    .pagination-info {
        font-size: 13px;
        width: 100%;
        text-align: center;
    }
    
    .pagination-controls {
        width: 100%;
        justify-content: center;
    }
    
    .pagination-rows-per-page {
        width: 100%;
        justify-content: center;
    }
    
    .pagination-btn {
        width: 28px;
        height: 28px;
    }
    
    .pagination-page {
        min-width: 28px;
        height: 28px;
        font-size: 13px;
    }
    
    .conflict-modal-content {
        max-width: 100%;
        margin: 10px;
    }
    
    .conflict-modal-body {
        padding: 20px;
        padding-bottom: 12px;
    }
    
    .conflict-modal-content .modal-footer {
        padding: 12px 20px 16px 20px;
    }
    
    .conflict-warning-icon {
        width: 64px;
        height: 64px;
    }
    
    .available-time-slot {
        padding: 10px;
    }
    
    .available-time-slot label {
        font-size: 13px;
    }
    
    .activities-modal-content {
        max-width: 95%;
    }
    
    .activities-modal-body {
        padding: 20px;
    }
    
    .activity-item {
        padding: 12px;
    }
    
    .activity-icon {
        width: 32px;
        height: 32px;
    }
    
    .recent-activity-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .recent-activity-header button {
        width: 100%;
    }
    
    .activity-filter-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .activity-filter-actions {
        flex-direction: column;
    }
    
    .activity-filter-actions button {
        width: 100%;
    }
    
    .activity-filter-section.expanded .activity-filter-content {
        max-height: 600px;
    }
}

/* Sidebar overlay for mobile */
@media (max-width: 768px) {
    .sidebar::after {
        content: '';
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: var(--sidebar-width);
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        visibility: hidden;
        transition: var(--transition);
    }
    
    .sidebar.open::after {
        opacity: 1;
        visibility: visible;
    }
    
    .sidebar {
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }
}

