/**
 * Custom CSS for PhD Time-Off Portal
 * Additional styles beyond TailwindCSS
 */

/* ===================================
   General Styles
   The design system itself (cards, buttons, forms, badges, tables) lives in
   public/vendor/tailwind/input.css and is compiled into tailwind.min.css.
   This file holds what Tailwind can't express: vendor widget skins
   (DataTables), keyframes, print rules and a few legacy helpers.
   =================================== */

:root {
    --primary-color: #2d4fe3;
    --primary-hover: #253ed0;
    --success-color: #059669;
    --danger-color: #e11d48;
    --warning-color: #d97706;
    --info-color: #426cef;
    --surface-border: #e2e8f0;
    --muted-text: #64748b;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    width: 100%;
}

/* ===================================
   Navigation Enhancements
   =================================== */

.app-navbar {
    background-color: rgba(255, 255, 255, 0.85);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
}

/* ===================================
   Mobile Menu Animation
   =================================== */

#mobile-menu {
    animation: slideDown 0.3s ease-out;
    transform-origin: top;
}

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

/* ===================================
   Loading Spinner
   =================================== */

.loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.35);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner:not(.hidden) {
    display: flex;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.35);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ===================================
   Flash Messages
   =================================== */

.flash-message {
    animation: slideInDown 0.3s ease-out;
}

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

/* ===================================
   Buttons (loading state only; .btn* come from the design system)
   =================================== */

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin-left: -9px;
    margin-top: -9px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===================================
   DataTables Customization
   Skins the vendored jquery.dataTables.min.css to match the design system.
   =================================== */

.dataTables_wrapper {
    padding: 0;
    font-size: 0.875rem;
    color: #334155;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    padding: 1rem 1.25rem;
    color: #64748b;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    padding: 0.875rem 1.25rem;
    color: #64748b !important;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    background-color: #fff;
    padding: 0.45rem 0.75rem;
    margin: 0 0.375rem;
    font-size: 0.875rem;
    color: #0f172a;
    box-shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dataTables_wrapper .dataTables_length select {
    padding-right: 2rem;
}

.dataTables_wrapper .dataTables_filter input {
    min-width: 14rem;
    margin-right: 0;
}

.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: #426cef;
    box-shadow: 0 0 0 4px rgba(45, 79, 227, 0.14);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 0.375rem 0.75rem !important;
    margin: 0 0.125rem;
    border-radius: 0.5rem !important;
    border: 1px solid transparent !important;
    color: #475569 !important;
    background: transparent !important;
    font-weight: 500;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: #2d4fe3 !important;
    color: #fff !important;
    border-color: #2d4fe3 !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current):not(.disabled) {
    background: #f1f5f9 !important;
    color: #0f172a !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    color: #cbd5e1 !important;
}

table.dataTable {
    border-collapse: collapse !important;
    width: 100% !important;
}

table.dataTable.no-footer {
    border-bottom: 1px solid #f1f5f9 !important;
}

table.dataTable thead th,
table.dataTable thead td {
    background-color: #f8fafc;
    border-bottom: 1px solid #e2e8f0 !important;
    border-top: 1px solid #e2e8f0;
    padding: 0.75rem 1rem !important;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}

table.dataTable tbody td {
    padding: 0.875rem 1rem !important;
    border-top: 1px solid #f1f5f9 !important;
    vertical-align: middle;
}

table.dataTable tbody tr {
    background-color: transparent !important;
}

table.dataTable tbody tr:hover {
    background-color: #f8fafc !important;
}

table.dataTable.display tbody tr.odd > .sorting_1,
table.dataTable.display tbody tr.even > .sorting_1,
table.dataTable.stripe tbody tr.odd,
table.dataTable.display tbody tr.odd {
    background-color: transparent !important;
}

/* ===================================
   Responsive Tables
   =================================== */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media screen and (max-width: 768px) {
    .table-responsive table {
        min-width: 600px;
    }
}

/* ===================================
   Form Styles (.form-* come from the design system)
   =================================== */

.form-group {
    margin-bottom: 1rem;
}

.form-label-required::after {
    content: ' *';
    color: var(--danger-color);
}

.form-input.error,
.form-select.error,
.form-textarea.error {
    border-color: var(--danger-color);
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.form-error {
    animation: fadeSlideIn 0.2s ease-out;
}

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

/* ===================================
   Status Indicators (.badge* come from the design system)
   =================================== */

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

.status-dot.approved {
    background-color: var(--success-color);
}

.status-dot.pending {
    background-color: var(--warning-color);
}

.status-dot.rejected {
    background-color: var(--danger-color);
}

/* ===================================
   Modal Styles
   =================================== */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.45);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.hidden {
    display: none !important;
}

.modal-content {
    background-color: white;
    border-radius: 1.125rem;
    width: calc(100% - 2rem);
    max-width: 32rem;
    max-height: calc(100vh - 2rem);
    margin: 1rem;
    overflow-y: auto;
    box-shadow: 0 32px 64px -16px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(15, 23, 42, 0.05);
    animation: modalSlideIn 0.2s ease-out;
}

@media (min-width: 640px) {
    .modal-content {
        width: auto;
        min-width: 24rem;
        margin: 0;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* ===================================
   Charts
   =================================== */

.chart-container {
    position: relative;
    height: 300px;
    margin: 1rem 0;
}

.chart-container-responsive {
    position: relative;
    height: 200px;
}

@media (min-width: 640px) {
    .chart-container-responsive {
        height: 250px;
    }
}

@media (min-width: 1024px) {
    .chart-container-responsive {
        height: 280px;
    }
}

/* ===================================
   Print Styles
   =================================== */

@media print {
    /* Hide navigation and footer when printing */
    nav,
    footer,
    .no-print {
        display: none !important;
    }

    /* Remove margins for print */
    body {
        margin: 0;
        padding: 0;
    }

    main {
        max-width: 100%;
        margin: 0;
        padding: 1rem;
    }

    /* Ensure tables break properly */
    table {
        page-break-inside: auto;
    }

    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    /* Remove box shadows for print */
    .card,
    .shadow,
    .shadow-lg {
        box-shadow: none !important;
        border: 1px solid #e5e7eb;
    }

    /* Print links with URLs */
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    /* Don't print external links */
    a[href^="http"]:after,
    a[href^="#"]:after {
        content: "";
    }

    /* Print background colors */
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ===================================
   Utility Classes
   =================================== */

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.hover-scale {
    transition: transform 0.2s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ===================================
   Responsive Utilities
   =================================== */

@media screen and (max-width: 640px) {
    .card-body {
        padding: 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }
}

/* ===================================
   Accessibility
   =================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus styles for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Remove default focus for mouse users */
*:focus:not(:focus-visible) {
    outline: none;
}

/* ===================================
   Custom Scrollbar
   =================================== */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
    border: 2px solid #f8fafc;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ===================================
   Micro-interactions & Hover Effects
   =================================== */

/* Link underline animation */
.link-underline {
    position: relative;
    text-decoration: none;
}

.link-underline::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background-color: currentColor;
    transition: width 0.2s ease;
}

.link-underline:hover::after {
    width: 100%;
}

/* Table row hover */
table tbody tr {
    transition: background-color 0.15s ease;
}

/* Action button group styling */
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.4rem 0.7rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.5rem;
    transition: all 0.15s ease;
    text-decoration: none;
}

.action-btn:hover {
    transform: translateY(-1px);
}

.action-btn-view {
    background-color: #eff4ff;
    color: #253ed0;
}

.action-btn-view:hover {
    background-color: #dce6fd;
}

.action-btn-approve {
    background-color: #ecfdf5;
    color: #047857;
}

.action-btn-approve:hover {
    background-color: #d1fae5;
}

.action-btn-reject {
    background-color: #fff1f2;
    color: #be123c;
}

.action-btn-reject:hover {
    background-color: #ffe4e6;
}

.action-btn-edit {
    background-color: #fffbeb;
    color: #b45309;
}

.action-btn-edit:hover {
    background-color: #fef3c7;
}

.action-btn-delete {
    background-color: #fff1f2;
    color: #be123c;
}

.action-btn-delete:hover {
    background-color: #ffe4e6;
}

/* Sticky sidebar with header offset */
.sidebar-sticky {
    position: sticky;
    top: 5rem; /* Account for navbar height + spacing */
}

/* Stat card subtle pulse on hover */
.stat-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

/* Progress bar animation */
.progress-bar {
    transition: width 0.5s ease-out;
}

/* Smooth icon rotation for dropdowns */
.dropdown-icon {
    transition: transform 0.2s ease;
}

.dropdown-open .dropdown-icon {
    transform: rotate(180deg);
}

/* Input field highlight on focus */
input:focus,
select:focus,
textarea:focus {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Notification badge pulse */
.notification-badge {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Skeleton loading animation */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Tooltip styling */
.tooltip {
    position: relative;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background-color: #0f172a;
    color: white;
    font-size: 0.75rem;
    border-radius: 0.5rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 50;
}

.tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Badge with dot indicator */
.badge-with-dot {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.badge-with-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
}
