/* PPM QMS - Custom Tailwind Configuration & Styles */

/* ===== Custom Utility Classes ===== */

/* Notification Slide Animation */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes progressShrink {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

.notification-slide-in {
    animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.notification-slide-out {
    animation: slideOutRight 0.3s cubic-bezier(0.7, 0, 0.84, 0) forwards;
}

.notification-progress {
    animation: progressShrink linear forwards;
}

/* ===== Scrollbar Styling ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #0c1925;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #2a628f;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3e92cc;
}

/* ===== Login Page ===== */
.login-bg {
    background: linear-gradient(135deg, #13293d 0%, #16324f 30%, #18435a 60%, #2a628f 100%);
    min-height: 100vh;
}

.login-card {
    background: rgba(19, 41, 61, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(62, 146, 204, 0.15);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.login-input {
    background: rgba(22, 50, 79, 0.6);
    border: 1px solid rgba(42, 98, 143, 0.4);
    color: #bdd5eb;
    transition: all 0.3s ease;
}

.login-input:focus {
    background: rgba(22, 50, 79, 0.8);
    border-color: #3e92cc;
    box-shadow: 0 0 0 3px rgba(62, 146, 204, 0.15);
    outline: none;
    color: #d8e9f5;
}

.login-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.login-input::placeholder {
    color: rgba(154, 193, 226, 0.5);
}

.login-btn {
    background: linear-gradient(135deg, #2a628f, #3e92cc);
    color: #fff;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.login-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #3e92cc, #64a7d6);
    box-shadow: 0 4px 20px rgba(62, 146, 204, 0.4);
    transform: translateY(-1px);
}

.login-btn:active:not(:disabled) {
    transform: translateY(0);
}

.login-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== Sidebar ===== */
.sidebar {
    background: linear-gradient(180deg, #13293d 0%, #16324f 100%);
    border-right: 1px solid rgba(42, 98, 143, 0.3);
    transition: width 0.3s ease;
    width: 260px;
    min-height: 100vh;
}

.sidebar.collapsed {
    width: 72px;
}

.sidebar-link {
    color: #9ac1e2;
    transition: all 0.2s ease;
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    text-decoration: none;
}

.sidebar-link:hover {
    background: rgba(42, 98, 143, 0.3);
    color: #d8e9f5;
}

.sidebar-link.active {
    background: rgba(62, 146, 204, 0.2);
    color: #64a7d6;
    font-weight: 600;
    border-left: 3px solid #3e92cc;
}

/* ===== Header ===== */
.app-header {
    background: rgba(19, 41, 61, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(42, 98, 143, 0.3);
}

/* ===== Table Styles ===== */
.qms-table-wrapper {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 600px;
    border: 1px solid rgba(42, 98, 143, 0.3);
    border-radius: 8px;
}

.qms-table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    white-space: nowrap;
}

.qms-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.qms-table thead th {
    background: #16324f;
    color: #9ac1e2;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 2px solid #2a628f;
    text-align: left;
}

.qms-table tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(42, 98, 143, 0.15);
    color: #bdd5eb;
    font-size: 0.875rem;
    white-space: nowrap;
}

.qms-table tbody tr {
    transition: background 0.15s ease;
}

.qms-table tbody tr:hover {
    background: rgba(42, 98, 143, 0.1);
}

.qms-table tbody tr:nth-child(even) {
    background: rgba(22, 50, 79, 0.3);
}

.qms-table tbody tr:nth-child(even):hover {
    background: rgba(42, 98, 143, 0.15);
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-btn {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8125rem;
    color: #9ac1e2;
    background: rgba(22, 50, 79, 0.5);
    border: 1px solid rgba(42, 98, 143, 0.3);
    transition: all 0.2s ease;
    cursor: pointer;
}

.pagination-btn:hover:not(:disabled) {
    background: rgba(42, 98, 143, 0.3);
    color: #d8e9f5;
}

.pagination-btn.active {
    background: #2a628f;
    color: #fff;
    border-color: #3e92cc;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== Modal ===== */
.modal-overlay {
    background: rgba(4, 8, 12, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #16324f;
    border: 1px solid rgba(42, 98, 143, 0.3);
    border-radius: 12px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-input {
    background: rgba(13, 30, 48, 0.8);
    border: 1px solid rgba(42, 98, 143, 0.4);
    color: #bdd5eb;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    width: 100%;
}

.modal-input:focus {
    border-color: #3e92cc;
    box-shadow: 0 0 0 3px rgba(62, 146, 204, 0.15);
    outline: none;
}

.modal-select {
    background: rgba(13, 30, 48, 0.8);
    border: 1px solid rgba(42, 98, 143, 0.4);
    color: #bdd5eb;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    width: 100%;
    cursor: pointer;
}

.modal-select:focus {
    border-color: #3e92cc;
    box-shadow: 0 0 0 3px rgba(62, 146, 204, 0.15);
    outline: none;
}

/* ===== Badge ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-active {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.badge-inactive {
    background: rgba(234, 179, 8, 0.15);
    color: #facc15;
}

.badge-locked {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* ===== Buttons ===== */
.btn-primary {
    background: linear-gradient(135deg, #2a628f, #3e92cc);
    color: #fff;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #3e92cc, #64a7d6);
    box-shadow: 0 4px 15px rgba(62, 146, 204, 0.3);
}

.btn-secondary {
    background: rgba(22, 50, 79, 0.6);
    color: #9ac1e2;
    font-weight: 500;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    border: 1px solid rgba(42, 98, 143, 0.4);
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-secondary:hover {
    background: rgba(42, 98, 143, 0.3);
    color: #d8e9f5;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    font-weight: 500;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    border: 1px solid rgba(239, 68, 68, 0.3);
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8125rem;
    min-height: 32px;
}

/* ===== Cards ===== */
.stat-card {
    background: rgba(22, 50, 79, 0.5);
    border: 1px solid rgba(42, 98, 143, 0.25);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: rgba(62, 146, 204, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* ===== Toggle Switch ===== */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: rgba(42, 98, 143, 0.3);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.toggle-switch.active {
    background: #2a628f;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #9ac1e2;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.toggle-switch.active::after {
    transform: translateX(20px);
    background: #64a7d6;
}

/* ===== Responsive adjustments ===== */

/* --- Mobile: up to 639px --- */
@media (max-width: 639px) {
    .sidebar {
        position: fixed;
        left: -260px;
        z-index: 50;
        transition: left 0.3s ease;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 40;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Table: ensure horizontal scroll, no wrapping */
    .qms-table-wrapper {
        max-height: 70vh;
    }

    .qms-table thead th {
        padding: 10px 12px;
        font-size: 0.6875rem;
    }

    .qms-table tbody td {
        padding: 8px 12px;
        font-size: 0.8125rem;
    }

    /* Buttons: touch-friendly sizing */
    .btn-primary,
    .btn-secondary,
    .btn-danger {
        padding: 8px 16px;
        font-size: 0.8125rem;
        min-height: 36px;
    }

    .btn-sm {
        padding: 6px 12px;
        font-size: 0.75rem;
        min-height: 32px;
    }

    /* Stat cards - tighter padding on mobile */
    .stat-card {
        padding: 16px;
    }

    /* Pagination compact */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }

    .pagination-btn {
        padding: 5px 10px;
        font-size: 0.75rem;
    }

    /* Modal - full width on very small screens */
    .modal-content {
        margin: 8px;
        max-height: 95vh;
    }
}

/* --- Small tablets: 640px - 767px --- */
@media (min-width: 640px) and (max-width: 767px) {
    .sidebar {
        position: fixed;
        left: -260px;
        z-index: 50;
        transition: left 0.3s ease;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 40;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .btn-sm {
        padding: 6px 14px;
        font-size: 0.8125rem;
        min-height: 32px;
    }
}

/* --- Tablets: 768px - 1023px --- */
@media (min-width: 768px) and (max-width: 1023px) {
    .sidebar {
        width: 220px;
    }

    .sidebar-link {
        font-size: 0.8125rem;
        padding: 8px 12px;
        gap: 10px;
    }

    .stat-card {
        padding: 16px;
    }
}

/* --- Desktop: 1024px+ --- */
@media (min-width: 1024px) {
    .sidebar {
        width: 260px;
    }
}

/* ===== Permission Checkbox Grid ===== */
.permission-section {
    background: rgba(13, 30, 48, 0.5);
    border: 1px solid rgba(42, 98, 143, 0.2);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.permission-section-title {
    color: #64a7d6;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(42, 98, 143, 0.2);
}

.permission-checkbox {
    accent-color: #3e92cc;
}

/* Countdown timer */
.countdown-ring {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid #2a628f;
    color: #64a7d6;
    font-weight: 700;
    font-size: 0.875rem;
}

/* ===== Action Dropdown Menu ===== */
.action-menu {
    display: block;
    min-width: 160px;
    padding: 4px 0;
    overflow: hidden;
}

.action-menu button,
.action-menu a {
    display: block;
    width: 100%;
    box-sizing: border-box;
    white-space: nowrap;
}

/* ===== Focus Visible States ===== */
*:focus-visible {
    outline: 2px solid #3e92cc;
    outline-offset: 2px;
}

/* ===== Loading spinner ===== */
.spinner {
    border: 3px solid rgba(42, 98, 143, 0.3);
    border-top-color: #3e92cc;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
