﻿/* =========================================================
   USER ROLES - MAIN
========================================================= */

.user-roles-page {
    direction: rtl;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    font-family: "Tajawal", "Segoe UI", Arial, sans-serif;
    color: #1e293b;
    box-sizing: border-box;
}

    .user-roles-page *,
    .user-roles-page *::before,
    .user-roles-page *::after {
        box-sizing: border-box;
    }


/* =========================================================
   HEADER
========================================================= */

.user-roles-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
    padding: 20px 24px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(15, 23, 42, 0.05);
}

    .user-roles-header h2 {
        margin: 0;
        font-size: 24px;
        font-weight: 800;
        color: #0f172a;
    }

    .user-roles-header p {
        margin: 6px 0 0;
        color: #64748b;
        font-size: 13px;
    }


/* =========================================================
   BUTTONS
========================================================= */

.user-roles-page .btn {
    border-radius: 9px;
    font-family: inherit;
    font-weight: 700;
    transition: all 0.2s ease;
}

.user-roles-page .btn-primary {
    background: #2563eb;
    border-color: #2563eb;
    padding: 10px 18px;
}

    .user-roles-page .btn-primary:hover {
        background: #1d4ed8;
        border-color: #1d4ed8;
        transform: translateY(-1px);
    }

.user-roles-page .btn-warning {
    color: #ffffff;
    background: #f59e0b;
    border-color: #f59e0b;
}

    .user-roles-page .btn-warning:hover {
        background: #d97706;
        border-color: #d97706;
    }

.user-roles-page .btn-danger {
    background: #dc2626;
    border-color: #dc2626;
}

    .user-roles-page .btn-danger:hover {
        background: #b91c1c;
        border-color: #b91c1c;
    }

.user-roles-page .btn-secondary {
    background: #64748b;
    border-color: #64748b;
}

    .user-roles-page .btn-secondary:hover {
        background: #475569;
        border-color: #475569;
    }


/* =========================================================
   ALERTS
========================================================= */

.user-roles-page .alert {
    border-radius: 10px;
    margin-bottom: 18px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
}

.user-roles-page .alert-success {
    color: #166534;
    background: #dcfce7;
    border: 1px solid #bbf7d0;
}

.user-roles-page .alert-danger {
    color: #991b1b;
    background: #fee2e2;
    border: 1px solid #fecaca;
}

.user-roles-page .alert-warning {
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fde68a;
}


/* =========================================================
   TABLE CONTAINER
========================================================= */

.roles-table-container {
    width: 100%;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(15, 23, 42, 0.05);
}


/* =========================================================
   TABLE
========================================================= */

.roles-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    text-align: right;
}

    .roles-table thead {
        background: #f8fafc;
    }

    .roles-table th {
        padding: 16px 18px;
        border-bottom: 2px solid #e2e8f0;
        color: #475569;
        font-size: 13px;
        font-weight: 800;
        white-space: nowrap;
    }

    .roles-table td {
        padding: 15px 18px;
        border-bottom: 1px solid #eef2f7;
        color: #334155;
        font-size: 14px;
        vertical-align: middle;
    }

    .roles-table tbody tr {
        transition: background 0.2s ease;
    }

        .roles-table tbody tr:hover {
            background: #f8fafc;
        }

        .roles-table tbody tr:last-child td {
            border-bottom: none;
        }


    /* =========================================================
   ID COLUMN
========================================================= */

    .roles-table .role-id {
        width: 70px;
        color: #64748b;
        font-weight: 700;
    }


    /* =========================================================
   ROLE NAME
========================================================= */

    .roles-table .role-name {
        font-weight: 700;
        color: #0f172a;
    }


    /* =========================================================
   USER COUNT
========================================================= */

    .roles-table .user-count {
        font-weight: 700;
        color: #475569;
    }


/* =========================================================
   ACTIONS
========================================================= */

.role-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: wrap;
}

    .role-actions .btn {
        min-width: 76px;
        padding: 7px 12px;
        font-size: 12px;
    }


/* =========================================================
   LOADING
========================================================= */

.roles-loading {
    padding: 50px 20px;
    text-align: center;
    color: #64748b;
    font-size: 14px;
}


/* =========================================================
   MODAL OVERLAY
========================================================= */

.roles-modal {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
}


    /* =========================================================
   MODAL
========================================================= */

    .roles-modal .modal-dialog {
        width: 100%;
        max-width: 500px;
        margin: 0;
    }

    .roles-modal .modal-content {
        width: 100%;
        overflow: hidden;
        border: none;
        border-radius: 16px;
        background: #ffffff;
        box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
    }


    /* =========================================================
   MODAL HEADER
========================================================= */

    .roles-modal .modal-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 15px;
        padding: 18px 22px;
        border-bottom: 1px solid #e2e8f0;
        background: #f8fafc;
    }

    .roles-modal .modal-title {
        margin: 0;
        color: #0f172a;
        font-size: 17px;
        font-weight: 800;
    }

    .roles-modal .btn-close {
        margin: 0;
    }


    /* =========================================================
   MODAL BODY
========================================================= */

    .roles-modal .modal-body {
        padding: 22px;
    }

    .roles-modal .form-group {
        margin-bottom: 18px;
    }

    .roles-modal label {
        display: block;
        margin-bottom: 8px;
        color: #334155;
        font-size: 13px;
        font-weight: 700;
    }

    .roles-modal .form-control {
        width: 100%;
        min-height: 44px;
        padding: 10px 13px;
        border: 1px solid #cbd5e1;
        border-radius: 9px;
        outline: none;
        font-family: inherit;
        font-size: 14px;
        transition: all 0.2s ease;
    }

        .roles-modal .form-control:focus {
            border-color: #2563eb;
            box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
        }


    /* =========================================================
   MODAL BUTTONS
========================================================= */

    .roles-modal .modal-body form > button,
    .roles-modal .modal-footer .btn {
        min-width: 90px;
        min-height: 40px;
    }

        .roles-modal .modal-body form > button + button {
            margin-right: 8px;
        }


/* =========================================================
   DELETE MODAL
========================================================= */

.delete-modal .modal-body {
    padding: 22px;
}

    .delete-modal .modal-body p {
        margin: 0 0 18px;
        color: #334155;
        font-size: 14px;
        line-height: 1.8;
    }

    .delete-modal .modal-body strong {
        color: #dc2626;
    }

.delete-modal .modal-footer {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    padding: 15px 22px;
    border-top: 1px solid #e2e8f0;
}


/* =========================================================
   FORM ERROR
========================================================= */

.roles-form-error {
    margin-bottom: 15px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 12px;
    font-weight: 600;
}


/* =========================================================
   TABLET
========================================================= */

@media (max-width: 900px) {

    .user-roles-page {
        padding: 16px;
    }

    .user-roles-header {
        padding: 18px;
    }

        .user-roles-header h2 {
            font-size: 21px;
        }

    .roles-table th,
    .roles-table td {
        padding: 13px 12px;
    }

    .role-actions {
        gap: 6px;
    }

        .role-actions .btn {
            min-width: 68px;
            padding: 6px 9px;
        }
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 768px) {

    .user-roles-page {
        padding: 10px;
    }

    .user-roles-header {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        margin-bottom: 15px;
        padding: 15px;
        border-radius: 12px;
    }

        .user-roles-header h2 {
            font-size: 19px;
        }

        .user-roles-header p {
            font-size: 11px;
        }

        .user-roles-header .btn {
            width: 100%;
            min-height: 44px;
        }


    /* TABLE AS CARDS */

    .roles-table-container {
        border: none;
        background: transparent;
        box-shadow: none;
        overflow: visible;
    }

    .roles-table,
    .roles-table tbody {
        display: block;
        width: 100%;
    }

        .roles-table thead {
            display: none;
        }

        .roles-table tbody {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .roles-table tr {
            display: block;
            width: 100%;
            padding: 10px 13px;
            background: #ffffff;
            border: 1px solid #e2e8f0;
            border-radius: 12px;
            box-shadow: 0 3px 10px rgba(15, 23, 42, 0.04);
        }

        .roles-table td {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 100%;
            min-height: 42px;
            padding: 8px 2px;
            border-bottom: 1px dashed #e2e8f0;
            text-align: left;
            gap: 12px;
        }

            .roles-table td:last-child {
                border-bottom: none;
            }

            .roles-table td::before {
                flex-shrink: 0;
                color: #64748b;
                font-size: 11px;
                font-weight: 800;
            }

            .roles-table td:nth-child(1)::before {
                content: "#";
            }

            .roles-table td:nth-child(2)::before {
                content: "اسم الصلاحية";
            }

            .roles-table td:nth-child(3)::before {
                content: "عدد المستخدمين";
            }

            .roles-table td:nth-child(4)::before {
                content: "الإجراءات";
            }

        .roles-table .role-id,
        .roles-table .role-name,
        .roles-table .user-count {
            width: auto;
        }

    .role-actions {
        justify-content: flex-end;
        max-width: 70%;
    }

        .role-actions .btn {
            min-width: 65px;
            min-height: 34px;
            padding: 6px 9px;
            font-size: 11px;
        }


    /* MODAL */

    .roles-modal {
        align-items: flex-start;
        padding: 10px;
        overflow-y: auto;
    }

        .roles-modal .modal-dialog {
            max-width: 100%;
            margin: 10px 0;
        }

        .roles-modal .modal-header {
            padding: 14px 16px;
        }

        .roles-modal .modal-body {
            padding: 16px;
        }

        .roles-modal .modal-title {
            font-size: 15px;
        }

        .roles-modal .modal-footer {
            padding: 12px 16px;
            flex-direction: column;
        }

            .roles-modal .modal-footer .btn {
                width: 100%;
            }

        .roles-modal .modal-body form > button {
            width: 100%;
            margin: 0 0 8px !important;
        }
}


/* =========================================================
   SMALL MOBILE
========================================================= */

@media (max-width: 480px) {

    .user-roles-page {
        padding: 7px;
    }

    .user-roles-header {
        padding: 13px;
    }

        .user-roles-header h2 {
            font-size: 17px;
        }

        .user-roles-header p {
            font-size: 10px;
        }

    .roles-table tr {
        padding: 8px 10px;
    }

    .roles-table td {
        font-size: 11px;
        min-height: 40px;
        gap: 8px;
    }

        .roles-table td::before {
            font-size: 9px;
        }

    .role-actions {
        gap: 5px;
    }

        .role-actions .btn {
            min-width: 58px;
            padding: 5px 7px;
            font-size: 10px;
        }

    .roles-modal {
        padding: 7px;
    }

        .roles-modal .modal-dialog {
            margin-top: 7px;
        }
}
