/**
 * AssessMY Admin CSS
 * Color palette based on UI mockups
 */

:root {
    /* Brand Colors */
    --primary-orange: #D97706;
    --primary-orange-hover: #B45309;
    --primary-orange-light: #FEF3C7;

    /* Status Colors */
    --success-green: #10B981;
    --success-light: #D1FAE5;
    --warning-orange: #F59E0B;
    --warning-light: #FEF3C7;
    --error-red: #EF4444;
    --error-light: #FEE2E2;
    --inactive-gray: #6B7280;

    /* Background Colors */
    --bg-white: #FFFFFF;
    --bg-light: #F9FAFB;
    --bg-gray: #F3F4F6;

    /* Text Colors */
    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;

    /* Border Colors */
    --border-color: #E5E7EB;
    --border-focus: #D97706;

    /* Layout Sizes */
    --sidebar-width: 280px;
    --sidebar-collapsed: 64px;
    --header-height: 60px;
    --content-padding: 24px;
}

/* Reset and Base */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    padding: 0;
}

/* Layout */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

.admin-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding-top: var(--header-height);
    transition: margin-left 0.3s ease;
}

.admin-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed);
}

.content-wrapper {
    padding: var(--content-padding);
}

/* Header */
.admin-header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    transition: left 0.3s ease;
}

.admin-header.sidebar-collapsed {
    left: var(--sidebar-collapsed);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-secondary);
    font-size: 20px;
}

.sidebar-toggle:hover {
    color: var(--text-primary);
}

/* Language Toggle */
.language-toggle {
    display: flex;
    gap: 4px;
}

.language-toggle .btn {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
}

.language-toggle .btn-lang {
    background: var(--bg-gray);
    color: var(--text-secondary);
    border: none;
}

.language-toggle .btn-lang.active {
    background: var(--primary-orange);
    color: white;
}

/* Notification Bell */
.notification-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-secondary);
    font-size: 18px;
}

.notification-btn:hover {
    color: var(--text-primary);
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--error-red);
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

/* User Dropdown */
.user-dropdown .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
}

.user-dropdown .dropdown-toggle::after {
    display: none;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-orange-light);
    color: var(--primary-orange);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

/* Sidebar */
.admin-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-white);
    border-right: 1px solid var(--border-color);
    z-index: 1001;
    transition: width 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.admin-sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-orange);
    text-decoration: none;
}

.admin-sidebar.collapsed .sidebar-logo span {
    display: none;
}

/* Navigation Menu */
.sidebar-nav {
    padding: 16px 0;
}

.nav-item {
    margin: 2px 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: var(--bg-gray);
    color: var(--text-primary);
}

.nav-link.active {
    color: var(--primary-orange);
    background: var(--primary-orange-light);
    border-left: 3px solid var(--primary-orange);
    margin-left: -3px;
}

.nav-link i {
    width: 20px;
    font-size: 16px;
    flex-shrink: 0;
}

.nav-link .nav-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 8px;
}

.nav-link .nav-arrow {
    transition: transform 0.2s ease;
    flex-shrink: 0;
    margin-left: auto;
}

.nav-link[aria-expanded="true"] .nav-arrow {
    transform: rotate(90deg);
}

/* Submenu */
.submenu {
    padding-left: 32px;
}

.submenu .nav-link {
    padding: 10px 16px;
    font-size: 13px;
}

/* Sidebar collapsed state */
.admin-sidebar.collapsed .nav-text,
.admin-sidebar.collapsed .nav-arrow {
    display: none;
}

.admin-sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 12px;
}

.admin-sidebar.collapsed .submenu {
    display: none;
}

/* Breadcrumb */
.breadcrumb-wrapper {
    margin-bottom: 16px;
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
}

.breadcrumb-item a {
    color: var(--primary-orange);
    text-decoration: none;
}

.breadcrumb-item.active {
    color: var(--text-secondary);
}

/* Page Title */
.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
}

/* Cards */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
}

.card-body {
    padding: 24px;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Search Input */
.search-input {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-input input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.search-input input:focus {
    outline: none;
    border-color: var(--border-focus);
}

.search-input i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Filter Dropdown */
.filter-dropdown {
    flex-shrink: 0;
}

.filter-dropdown .btn {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 10px 16px;
    font-size: 14px;
}

.filter-dropdown .form-select {
    min-width: 160px;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    height: 40px;
    padding: 8px 24px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* Dropdown buttons - fix text/arrow alignment */
.btn.dropdown-toggle {
    padding-right: 32px;
    position: relative;
}

.btn.dropdown-toggle::after {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0;
}

.btn-primary {
    background: var(--primary-orange);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-orange-hover);
    color: white;
}

.btn-outline-primary {
    background: white;
    border: 1px solid var(--primary-orange);
    color: var(--primary-orange);
}

.btn-outline-primary:hover {
    background: var(--primary-orange);
    color: white;
}

.btn-danger {
    background: var(--error-red);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
    color: white;
}

.btn-outline-secondary {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background: var(--bg-gray);
}

/* Tables */
.table {
    width: 100%;
    margin-bottom: 0;
}

.table thead th {
    background: var(--bg-gray);
    font-weight: 500;
    color: var(--text-primary);
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background: var(--bg-light);
}

/* Status Badges */
.badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-active, .badge-success {
    background: var(--success-green);
    color: white;
}

.badge-inactive {
    background: var(--inactive-gray);
    color: white;
}

.badge-draft, .badge-warning, .badge-in-progress {
    background: var(--warning-orange);
    color: white;
}

.badge-rejected, .badge-danger {
    background: var(--error-red);
    color: white;
}

.badge-success-light {
    background: var(--success-light);
    color: var(--success-green);
}

.badge-warning-light {
    background: var(--warning-light);
    color: var(--warning-orange);
}

.badge-danger-light {
    background: var(--error-light);
    color: var(--error-red);
}

/* Action Buttons */
.action-btns {
    display: flex;
    gap: 8px;
}

.btn-action {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-action:hover {
    background: var(--bg-gray);
    color: var(--text-primary);
}

.btn-action.delete:hover {
    background: var(--error-light);
    color: var(--error-red);
}

/* Forms */
.form-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--error-red);
}

.form-control, .form-select {
    height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

/* Fix select dropdown text not overlapping with arrow */
.form-select {
    padding-right: 42px;
    padding-left: 14px;
    background-position: right 14px center;
    background-size: 14px 10px;
    text-overflow: ellipsis;
    min-width: 140px;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

/* Radio & Checkbox */
.form-check-input:checked {
    background-color: var(--primary-orange);
    border-color: var(--primary-orange);
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.2);
}

/* Toggle Switch */
.form-switch .form-check-input {
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.form-switch .form-check-input:checked {
    background-color: var(--primary-orange);
}

/* Modals */
.modal-content {
    border-radius: 8px;
    border: none;
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
}

.modal-title {
    font-weight: 600;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    border-top: none;
    padding: 16px 24px;
}

/* Delete Modal */
.delete-modal .modal-body {
    text-align: center;
    padding: 32px 24px;
}

.delete-modal .warning-icon {
    width: 64px;
    height: 64px;
    background: var(--warning-light);
    color: var(--warning-orange);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 16px;
}

/* Tabs */
.nav-tabs {
    border-bottom: 1px solid var(--border-color);
}

.nav-tabs .nav-link {
    color: var(--text-secondary);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 12px 20px;
    font-weight: 500;
    margin-bottom: -1px;
}

.nav-tabs .nav-link:hover {
    color: var(--text-primary);
    border-color: transparent;
}

.nav-tabs .nav-link.active {
    color: var(--primary-orange);
    border-bottom-color: var(--primary-orange);
    background: transparent;
}

/* Pagination */
.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 14px;
}

.pagination {
    margin: 0;
}

.page-link {
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
}

.page-link:hover {
    background: var(--bg-gray);
    color: var(--text-primary);
}

.page-item.active .page-link {
    background: var(--primary-orange);
    border-color: var(--primary-orange);
}

/* Three-dot Menu */
.dropdown-menu {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 4px;
}

.dropdown-item {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
}

.dropdown-item:hover {
    background: var(--bg-gray);
}

.dropdown-item.text-danger:hover {
    background: var(--error-light);
}

/* Alerts */
.alert {
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.alert-success {
    background: var(--success-light);
    color: var(--success-green);
    border: 1px solid var(--success-green);
}

.alert-danger {
    background: var(--error-light);
    color: var(--error-red);
    border: 1px solid var(--error-red);
}

.alert-warning {
    background: var(--warning-light);
    color: var(--warning-orange);
    border: 1px solid var(--warning-orange);
}

/* Permission Matrix */
.permission-matrix .table th,
.permission-matrix .table td {
    text-align: center;
    vertical-align: middle;
}

.permission-matrix .table th:first-child,
.permission-matrix .table td:first-child,
.permission-matrix .table th:nth-child(2),
.permission-matrix .table td:nth-child(2) {
    text-align: left;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 40px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-orange);
    margin: 0;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form .form-check {
    margin-bottom: 24px;
}

.login-form .btn-login {
    width: 100%;
    height: 44px;
}

.forgot-password-link {
    text-align: center;
    margin-top: 16px;
}

.forgot-password-link a {
    color: var(--primary-orange);
    text-decoration: none;
}

.forgot-password-link a:hover {
    text-decoration: underline;
}

/* ============================================
   RESPONSIVE STYLES
   ============================================ */

/* Large tablets and small desktops */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
        --content-padding: 20px;
    }

    .page-title {
        font-size: 24px;
    }
}

/* Tablets */
@media (max-width: 768px) {
    :root {
        --content-padding: 16px;
        --header-height: 56px;
    }

    /* Sidebar - slide out on mobile */
    .admin-sidebar {
        transform: translateX(-100%);
        width: 280px;
        z-index: 1050;
    }

    .admin-sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
    }

    /* Overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1049;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .admin-content {
        margin-left: 0;
    }

    .admin-header {
        left: 0;
        padding: 0 16px;
    }

    .admin-header.sidebar-collapsed {
        left: 0;
    }

    /* Page title */
    .page-title {
        font-size: 22px;
        margin-bottom: 16px;
    }

    /* Toolbar - stack vertically */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .toolbar-left {
        flex-direction: column;
        width: 100%;
    }

    .toolbar-right {
        width: 100%;
    }

    .toolbar-right .btn {
        width: 100%;
    }

    .search-input {
        max-width: none;
        width: 100%;
    }

    .filter-dropdown {
        width: 100%;
    }

    .filter-dropdown .form-select {
        width: 100%;
    }

    /* Cards */
    .card-body {
        padding: 16px;
    }

    /* Tables */
    .table thead th,
    .table tbody td {
        padding: 10px 12px;
        font-size: 13px;
    }

    .table thead th {
        white-space: nowrap;
    }

    /* Action buttons in tables */
    .action-btns {
        gap: 4px;
    }

    .btn-action {
        width: 28px;
        height: 28px;
    }

    /* Three-dot dropdown menus */
    .dropdown-menu {
        min-width: 140px;
    }

    /* Buttons */
    .btn {
        height: 38px;
        padding: 8px 16px;
        font-size: 13px;
    }

    /* Forms */
    .form-control, .form-select {
        height: 38px;
        font-size: 14px;
    }

    /* Modals */
    .modal-dialog {
        margin: 16px;
    }

    /* Pagination */
    .pagination-wrapper {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .pagination-wrapper .col-sm-6 {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    /* Language toggle */
    .language-toggle .btn {
        padding: 4px 10px;
        font-size: 11px;
    }

    /* User dropdown */
    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

/* Mobile phones */
@media (max-width: 576px) {
    :root {
        --content-padding: 12px;
    }

    /* Header adjustments */
    .header-right {
        gap: 8px;
    }

    .language-toggle {
        display: none; /* Hide on very small screens or make it a dropdown */
    }

    /* Page title */
    .page-title {
        font-size: 20px;
        margin-bottom: 12px;
    }

    /* Cards */
    .card {
        border-radius: 6px;
    }

    .card-body {
        padding: 12px;
    }

    /* Toolbar */
    .toolbar {
        gap: 10px;
        margin-bottom: 16px;
    }

    .toolbar-left {
        gap: 8px;
    }

    /* Buttons */
    .btn {
        height: 36px;
        padding: 6px 14px;
        font-size: 13px;
        gap: 6px;
    }

    .btn i {
        font-size: 14px;
    }

    /* Forms */
    .form-control, .form-select {
        height: 36px;
        padding: 6px 10px;
        font-size: 13px;
    }

    .form-select {
        padding-right: 38px;
        min-width: 120px;
    }

    /* Tables - smaller on mobile */
    .table-responsive {
        margin: 0 -12px;
        padding: 0 12px;
    }

    .table thead th,
    .table tbody td {
        padding: 8px 10px;
        font-size: 12px;
    }

    /* Hide less important columns on very small screens */
    .table .hide-mobile {
        display: none;
    }

    /* Badges */
    .badge {
        padding: 3px 8px;
        font-size: 11px;
    }

    /* Action buttons - use three-dot menu on mobile */
    .action-btns {
        gap: 2px;
    }

    .btn-action {
        width: 26px;
        height: 26px;
    }

    .btn-action i {
        font-size: 12px;
    }

    /* Three-dot dropdown trigger */
    .dropdown-toggle.btn-action {
        padding: 0;
    }

    /* Login page */
    .login-card {
        padding: 24px 20px;
        margin: 16px;
    }

    .login-logo h1 {
        font-size: 28px;
    }

    /* Sidebar when open */
    .admin-sidebar.show {
        width: 85vw;
        max-width: 300px;
    }

    /* Navigation */
    .nav-link {
        padding: 10px 14px;
        font-size: 14px;
    }

    .submenu .nav-link {
        padding: 8px 14px;
        font-size: 13px;
    }

    /* Breadcrumb */
    .breadcrumb {
        font-size: 12px;
    }

    /* Permission matrix table */
    .permission-matrix .table th,
    .permission-matrix .table td {
        padding: 8px 6px;
        font-size: 12px;
    }

    /* Toggle switch in permission table */
    .form-switch .form-check-input {
        width: 36px;
        height: 20px;
    }
}

/* Very small phones */
@media (max-width: 375px) {
    :root {
        --content-padding: 10px;
    }

    .page-title {
        font-size: 18px;
    }

    .btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .table thead th,
    .table tbody td {
        padding: 6px 8px;
        font-size: 11px;
    }

    .card-body {
        padding: 10px;
    }

    /* Hide even more columns */
    .table .hide-xs {
        display: none;
    }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .admin-sidebar.show {
        width: 280px;
    }

    .content-wrapper {
        padding-top: 8px;
    }
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
    .admin-sidebar {
        -webkit-overflow-scrolling: touch;
    }

    .form-select {
        -webkit-appearance: none;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-size: 12px;
    }
}

/* Print styles */
@media print {
    .admin-sidebar,
    .admin-header,
    .toolbar,
    .action-btns,
    .pagination-wrapper {
        display: none !important;
    }

    .admin-content {
        margin-left: 0 !important;
        padding-top: 0 !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
