/**
 * CoffeePot Hub - Custom Styles
 */

/* ============================================
   CSS Variables / Theme Customization
   ============================================ */
:root {
    --primary-color: #667eea;
    --primary-hover: #5a6fd6;
    --secondary-color: #764ba2;
    --sidebar-bg: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-active: #ffffff;
}

/* ============================================
   Layout Adjustments
   ============================================ */
.page-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-body {
    flex: 1;
}

/* ============================================
   Sidebar — Registry-Driven (Tabler navbar-vertical)
   ============================================ */
.navbar-vertical {
    background: var(--sidebar-bg) !important;
}

/* Force all sidebar text to use our CSS variables (override Tabler defaults) */
.navbar-vertical .nav-link {
    color: var(--sidebar-text) !important;
    border-radius: 0.375rem;
    margin: 2px 8px;
    padding: 0.5rem 0.75rem;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.navbar-vertical .nav-link:hover {
    color: var(--sidebar-text-hover) !important;
    background: var(--sidebar-active-hl) !important;
}

.navbar-vertical .nav-link.active,
.navbar-vertical .nav-link.show {
    color: var(--sidebar-text-hover) !important;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%) !important;
}

.navbar-vertical .nav-link-icon {
    width: 24px;
    text-align: center;
    color: inherit !important;
}

/* Collapsible children — Tabler dropdown-menu pattern */
.navbar-vertical .dropdown-menu {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0.25rem 0 !important;
    position: static !important;
}

.navbar-vertical .dropdown-item {
    color: var(--sidebar-text) !important;
    padding: 0.4rem 0.75rem 0.4rem 2.75rem;
    margin: 1px 8px;
    font-size: 0.8125rem;
    border-radius: 0.375rem;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
}

.navbar-vertical .dropdown-item:hover,
.navbar-vertical .dropdown-item:focus {
    color: var(--sidebar-text-hover) !important;
    background: var(--sidebar-active-hl) !important;
}

.navbar-vertical .dropdown-item.active {
    color: var(--sidebar-text-hover) !important;
    background: var(--sidebar-active-hl) !important;
    border-left-color: var(--sidebar-text-hover);
}

/* Collapse toggle arrow */
.navbar-vertical .dropdown-toggle::after {
    border: solid var(--sidebar-text) !important;
    border-width: 0 2px 2px 0 !important;
    display: inline-block;
    padding: 2.5px;
    transform: rotate(-45deg);
    transition: transform 0.2s ease;
    margin-left: auto;
}

.navbar-vertical .dropdown-toggle[aria-expanded="true"]::after,
.navbar-vertical .dropdown-toggle.show::after {
    transform: rotate(45deg);
}

/* Section labels */
.navbar-vertical .sidebar-section-label {
    color: var(--sidebar-text-muted) !important;
    letter-spacing: 0.05em;
    font-size: 0.65rem;
    font-weight: 600;
}

/* Mobile offcanvas sidebar */
#mobileSidebar .sidebar-collapse-toggle::after {
    content: '';
    border: solid var(--sidebar-text);
    border-width: 0 2px 2px 0;
    display: inline-block;
    padding: 3px;
    transform: rotate(-45deg);
    transition: transform 0.2s ease;
}

#mobileSidebar .sidebar-collapse-toggle[aria-expanded="true"]::after {
    transform: rotate(45deg);
}

#mobileSidebar a:hover {
    background: var(--sidebar-active-hl) !important;
    color: var(--sidebar-text-hover) !important;
}

/* ============================================
   Card Styles
   ============================================ */
.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s ease;
}

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

.card-header {
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* ============================================
   Button Enhancements
   ============================================ */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: none;
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--secondary-color) 100%);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ============================================
   Form Styles
   ============================================ */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(102, 126, 234, 0.25);
}

.form-label.required::after {
    content: " *";
    color: #dc3545;
}

/* ============================================
   Table Styles
   ============================================ */
.table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    color: #6c757d;
}

.table-hover tbody tr:hover {
    background-color: rgba(102, 126, 234, 0.05);
}

/* DataTables overrides */
.dataTables_wrapper {
    overflow: visible;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid #dee2e6 !important;
    border-radius: 0.375rem !important;
    padding: 0.375rem 0.75rem !important;
    outline: none !important;
    box-shadow: none !important;
}

.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 0.25rem rgba(102, 126, 234, 0.25) !important;
    outline: none !important;
}

.dataTables_wrapper > .row:first-child {
    padding: 4px 0;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 0.375rem !important;
    margin: 0 2px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%) !important;
    border-color: transparent !important;
    color: white !important;
}

/* Prevent horizontal scroll on tables */
.table-responsive,
.dataTables_scrollBody {
    overflow-x: auto;
}

.table {
    table-layout: auto;
    width: 100% !important;
    word-wrap: break-word;
}

.table td,
.table th {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

.table td:last-child,
.table th:last-child {
    white-space: nowrap;
    overflow: visible;
    max-width: none;
}

/* Ensure page doesn't scroll horizontally */
.page-wrapper {
    overflow-x: hidden;
}

.page-body .container-xl {
    overflow-x: hidden;
}

/* ============================================
   Alert Styles
   ============================================ */
.alert {
    border: none;
    border-radius: 0.5rem;
}

.alert-success {
    background: rgba(25, 135, 84, 0.1);
    color: #0f5132;
}

.alert-danger {
    background: rgba(220, 53, 69, 0.1);
    color: #842029;
}

.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    color: #664d03;
}

.alert-info {
    background: rgba(13, 202, 240, 0.1);
    color: #055160;
}

/* ============================================
   Action Buttons (DataTable rows)
   ============================================ */
.btn-actions {
    display: inline-flex;
    gap: 4px;
    white-space: nowrap;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    background: transparent;
    color: #6c757d;
    transition: all 0.15s ease;
}

.btn-action:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.btn-action.text-danger:hover {
    background: #d63939;
    border-color: #d63939;
    color: #fff;
}

.btn-action.text-warning:hover {
    background: #f59f00;
    border-color: #f59f00;
    color: #fff;
}

.btn-action.text-success:hover {
    background: #2fb344;
    border-color: #2fb344;
    color: #fff;
}

/* ============================================
   Badge Styles
   ============================================ */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

/* ============================================
   Modal Styles
   ============================================ */
.modal-content {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.modal-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.modal-status {
    height: 4px;
    border-radius: 0.75rem 0.75rem 0 0;
}

/* ============================================
   Toast Styles
   ============================================ */
.toast {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.toast-header {
    border-radius: 0.5rem 0.5rem 0 0;
}

/* ============================================
   Avatar Styles
   ============================================ */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
}

.avatar-md {
    width: 40px;
    height: 40px;
    font-size: 0.875rem;
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 1.25rem;
}

/* ============================================
   Status Indicator
   ============================================ */
.status {
    display: inline-flex;
    align-items: center;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

.status-dot-animated {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 currentColor;
        opacity: 1;
    }
    70% {
        box-shadow: 0 0 0 6px currentColor;
        opacity: 0;
    }
    100% {
        box-shadow: 0 0 0 0 currentColor;
        opacity: 0;
    }
}

.status-green .status-dot {
    background: #2fb344;
}

.status-red .status-dot {
    background: #d63939;
}

.status-yellow .status-dot {
    background: #f59f00;
}

/* ============================================
   Loading States
   ============================================ */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   Utility Classes
   ============================================ */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

/* ============================================
   Notification Badge & Dropdown
   ============================================ */
.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    background: #d63939;
    color: #fff;
    animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
    0% { box-shadow: 0 0 0 0 rgba(214, 57, 57, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(214, 57, 57, 0); }
    100% { box-shadow: 0 0 0 0 rgba(214, 57, 57, 0); }
}

.notification-dropdown {
    width: 360px;
    max-height: 420px;
    padding: 0;
    z-index: 1050;
}

.notification-dropdown .dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.notification-dropdown .notification-list {
    max-height: 320px;
    overflow-y: auto;
}

.notification-dropdown .notification-item {
    display: flex;
    align-items: flex-start;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    transition: background 0.15s ease;
    text-decoration: none;
    color: inherit;
}

.notification-dropdown .notification-item:hover {
    background: rgba(102, 126, 234, 0.05);
}

.notification-dropdown .notification-item.unread {
    background: rgba(102, 126, 234, 0.03);
}

.notification-dropdown .notification-item .notification-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 0.75rem;
    font-size: 1rem;
}

.notification-dropdown .notification-item .notification-content {
    flex: 1;
    min-width: 0;
}

.notification-dropdown .notification-item .notification-title {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 2px;
}

.notification-dropdown .notification-item .notification-text {
    font-size: 0.8rem;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notification-dropdown .notification-item .notification-time {
    font-size: 0.75rem;
    color: #adb5bd;
    margin-top: 2px;
}

.notification-dropdown .dropdown-footer {
    padding: 0.5rem 1rem;
    text-align: center;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state .empty-state-icon {
    font-size: 3rem;
    color: #adb5bd;
    margin-bottom: 1rem;
}

.empty-state .empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state .empty-state-description {
    color: #6c757d;
    max-width: 400px;
    margin: 0 auto;
}

/* ============================================
   Feedback Widget
   ============================================ */
.feedback-widget-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: #fff;
    border: none;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 1040;
}

.feedback-widget-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

/* ============================================
   Filter Row
   ============================================ */
.filter-row {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .navbar,
    .sidebar,
    .btn,
    .no-print {
        display: none !important;
    }

    .page-body {
        padding: 0 !important;
        margin: 0 !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 991.98px) {
    .navbar-vertical {
        position: fixed;
        z-index: 1030;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .navbar-vertical.show {
        transform: translateX(0);
    }
}
