/* ============================================
   ATG Group - Approval System
   Modern UI - Inspired by Financial Dashboard
   ============================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --pink: #E91E63;
    --pink-light: #F472B6;
    --purple: #9F7AEA;
    --purple-dark: #7C5BD3;
    --blue: #1E5A8E;
    --blue-light: #2D7DBF;
    --skyblue: #2EA9DC;
    --green: #0F9B8E;
    --green-light: #8BC053;
    --orange: #F4A300;
    --red: #D32F2F;
    --bg: #F2F4F8;
    --white: #FFFFFF;
    --text: #2C2C3E;
    --text-light: #7A7A8C;
    --border: #ECECF3;
    --shadow: 0 8px 22px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 20px 60px rgba(20, 20, 40, 0.08);
}

body {
    font-family: 'Cairo', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ===== Layout ===== */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 270px;
    background: linear-gradient(180deg, #1E1E2E 0%, #2C2C3E 100%);
    color: white;
    padding: 24px 0;
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    box-shadow: -4px 0 20px rgba(0,0,0,0.05);
}

.sidebar .brand {
    padding: 0 24px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar .brand .logo {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--pink), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
    font-size: 22px;
    font-weight: 900;
    box-shadow: 0 8px 20px rgba(233, 30, 99, 0.32);
}

.sidebar .brand h2 {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.sidebar .brand small {
    display: block;
    font-size: 11px;
    opacity: 0.7;
    font-weight: 400;
    margin-top: 2px;
}

.sidebar .menu {
    padding: 18px 12px;
}

.sidebar .menu-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.4);
    padding: 12px 14px 6px;
    font-weight: 700;
}

.sidebar .menu a,
.sidebar .menu summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: rgba(255,255,255,0.75);
    border-radius: 10px;
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.sidebar .menu summary {
    cursor: pointer;
    list-style: none;
}

.sidebar .menu summary::-webkit-details-marker {
    display: none;
}

.sidebar .menu a:hover,
.sidebar .menu summary:hover {
    background: rgba(255,255,255,0.06);
    color: white;
}

.sidebar .menu a.active,
.sidebar .menu details.active > summary {
    background: linear-gradient(95deg, var(--pink), var(--purple));
    color: white;
    box-shadow: 0 6px 18px rgba(233, 30, 99, 0.35);
}

.sidebar .menu a .ico,
.sidebar .menu summary .ico {
    width: 22px;
    text-align: center;
    font-size: 16px;
}

.sidebar .menu a .badge,
.sidebar .menu summary .badge {
    margin-right: auto;
    background: var(--pink);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.sidebar .menu details {
    margin-bottom: 4px;
}

.sidebar .menu summary .chev {
    margin-right: auto;
    font-size: 14px;
    opacity: 0.75;
    transition: transform 0.2s;
}

.sidebar .menu summary .badge + .chev {
    margin-right: 8px;
}

.sidebar .menu details[open] summary .chev {
    transform: rotate(180deg);
}

.sidebar .menu .submenu {
    margin: 2px 15px 8px 0;
    padding: 4px 10px 0 0;
    border-right: 1px solid rgba(255,255,255,0.08);
}

.sidebar .menu .submenu a {
    padding: 10px 12px;
    margin-bottom: 3px;
    font-size: 13px;
}

.sidebar .menu .submenu a.active {
    box-shadow: none;
}

.main {
    flex: 1;
    margin-right: 270px;
    padding: 24px 32px;
}

/* ===== Topbar ===== */
.topbar {
    background: white;
    border-radius: 18px;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
}

.topbar .greet h1 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
}

.topbar .greet small {
    color: var(--text-light);
    font-size: 13px;
}

.topbar .user-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar .user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    padding: 8px 14px;
    border-radius: 30px;
}

.topbar .avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pink), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 15px;
}

.topbar .user-pill .nm {
    font-size: 13px;
    font-weight: 700;
}

.topbar .user-pill .rl {
    font-size: 11px;
    color: var(--text-light);
}

.topbar .icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--bg);
    border: none;
    cursor: pointer;
    font-size: 18px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.topbar .icon-btn:hover {
    background: #E5E7EB;
}

.topbar .icon-btn .dot {
    position: absolute;
    top: 8px;
    left: 10px;
    width: 9px;
    height: 9px;
    background: var(--red);
    border-radius: 50%;
    border: 2px solid white;
}

/* ===== Cards ===== */
.card {
    background: white;
    border-radius: 18px;
    padding: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.card-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title::before {
    content: "";
    width: 5px;
    height: 22px;
    background: linear-gradient(180deg, var(--pink), var(--purple));
    border-radius: 4px;
}

.card-title small {
    font-weight: 400;
    color: var(--text-light);
    font-size: 12px;
    margin-right: 8px;
}

/* ===== KPI Cards ===== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 22px;
}

.kpi-card {
    border-radius: 18px;
    padding: 22px;
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
    min-height: 130px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

a.kpi-card {
    cursor: pointer;
}

a.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(20, 20, 40, 0.14);
}

.kpi-card .icon {
    position: absolute;
    top: 16px;
    left: 18px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.kpi-card .label {
    font-size: 13px;
    font-weight: 600;
    opacity: 0.95;
    margin-top: 30px;
}

.kpi-card .value {
    font-size: 30px;
    font-weight: 800;
    margin-top: 4px;
    font-family: 'Tajawal', sans-serif;
}

.kpi-card .value.money-value {
    font-size: 26px;
    line-height: 1.15;
    word-break: break-word;
}

.kpi-card .sub {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 4px;
}

.kpi-pink { background: linear-gradient(140deg, #E91E63, #F06292); }
.kpi-purple { background: linear-gradient(140deg, #7C5BD3, #A98AF1); }
.kpi-blue { background: linear-gradient(140deg, #1E5A8E, #2D7DBF); }
.kpi-green { background: linear-gradient(140deg, #0F9B8E, #4FBDB1); }
.kpi-orange { background: linear-gradient(140deg, #F4A300, #FFC857); }
.kpi-red { background: linear-gradient(140deg, #D32F2F, #E57373); }
.kpi-skyblue { background: linear-gradient(140deg, #2EA9DC, #5BC4ED); }

/* ===== Tables ===== */
.table-wrap {
    background: white;
    border-radius: 18px;
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
}

.table-head {
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.table-head h3 {
    font-size: 17px;
    font-weight: 800;
}

.table-search {
    display: flex;
    gap: 10px;
    align-items: center;
}

.table-search form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.table-search input,
.table-search select {
    padding: 9px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: 'Cairo';
    font-size: 13px;
    background: var(--bg);
    min-height: 42px;
}

.table-search input[type="search"],
.table-search input[type="text"] {
    width: 240px;
}

.table-search input[type="date"] {
    width: 150px;
}

.table-search select {
    min-width: 145px;
}

.table-search input:focus,
.table-search select:focus {
    outline: none;
    border-color: var(--pink);
    background: white;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
}

table.data-table th {
    background: var(--bg);
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    text-align: right;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table.data-table td {
    padding: 14px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

table.data-table tr:hover {
    background: #FAFAFC;
}

table.data-table tr:last-child td {
    border-bottom: none;
}

.code-pill {
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 6px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 700;
    color: var(--purple-dark);
    font-size: 12px;
    display: inline-block;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-cell .av {
    width: 34px;
    height: 34px;
    min-width: 34px;
    max-width: 34px;
    min-height: 34px;
    max-height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--purple), var(--pink));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    overflow: hidden;
    flex-shrink: 0;
}

.user-cell .av img {
    width: 34px !important;
    height: 34px !important;
    max-width: 34px !important;
    max-height: 34px !important;
    min-width: 34px !important;
    min-height: 34px !important;
    object-fit: cover !important;
    display: block !important;
    border-radius: 50% !important;
}

.user-cell .nm {
    font-weight: 700;
    color: var(--text);
}

.user-cell .em {
    font-size: 11px;
    color: var(--text-light);
}

/* ===== Status Badges ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
}

.status-badge.good { background: #E5F8F2; color: var(--green); }
.status-badge.bad { background: #FFE6E6; color: var(--red); }
.status-badge.warn { background: #FFF4DC; color: var(--orange); }
.status-badge.info { background: #EAF1F9; color: var(--blue); }
.status-badge.neutral { background: var(--bg); color: var(--text-light); }

.priority-pill {
    color: white;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
}

/* ===== Buttons ===== */
.btn {
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    font-family: 'Cairo';
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(95deg, var(--pink), var(--purple));
    color: white;
    box-shadow: 0 6px 16px rgba(233, 30, 99, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(233, 30, 99, 0.4);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
}

.btn-secondary:hover { background: #E5E7EB; }

.btn-success {
    background: linear-gradient(95deg, var(--green), #4FBDB1);
    color: white;
}

.btn-danger {
    background: linear-gradient(95deg, var(--red), #E57373);
    color: white;
}

.btn-warning {
    background: linear-gradient(95deg, var(--orange), #FFC857);
    color: white;
}

.btn-sm { padding: 7px 14px; font-size: 12px; }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    justify-content: center;
}

/* ===== Forms ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.cols-1 { grid-template-columns: 1fr; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full { grid-column: 1 / -1; }

.form-group label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.form-group label .req {
    color: var(--red);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: 'Cairo';
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--pink);
    background: white;
    box-shadow: 0 0 0 3px rgba(233, 30, 99, 0.08);
}

.form-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%237A7A8C'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 12px center;
    background-size: 18px;
    padding-left: 40px !important;
    cursor: pointer;
}

.form-group select option {
    padding: 10px;
    font-family: 'Cairo', sans-serif;
    direction: rtl;
    background: white;
    color: var(--text);
}

.priority-field select {
    border-color: var(--pink);
    background-color: white;
}

.form-group small.hint {
    color: var(--text-light);
    font-size: 11px;
}

.form-group textarea { resize: vertical; min-height: 100px; }

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

/* ===== Modals ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 40, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: white;
    border-radius: 22px;
    padding: 28px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--bg);
}

.modal-head h3 {
    font-size: 18px;
    font-weight: 800;
}

.modal-head .close {
    background: var(--bg);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
}

/* ===== Login Page ===== */
.login-bg {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--pink) 0%, var(--purple-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-box {
    background: white;
    border-radius: 28px;
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.2);
}

.login-box .logo {
    width: 82px;
    height: 82px;
    border-radius: 24px;
    background: linear-gradient(135deg, var(--pink), var(--purple));
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 40px;
    font-weight: 900;
    box-shadow: 0 14px 36px rgba(233, 30, 99, 0.3);
}

.login-box h1 {
    text-align: center;
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 6px;
}

.login-box .subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
    margin-bottom: 28px;
}

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

.login-box .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 14px;
    margin-top: 8px;
    font-size: 15px;
}

/* ===== Notification ===== */
.notify {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 26px;
    border-radius: 12px;
    color: white;
    font-weight: 700;
    z-index: 9999;
    animation: slideDown 0.3s;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.notify.success { background: var(--green); }
.notify.error { background: var(--red); }
.notify.warning { background: var(--orange); }

@keyframes slideDown {
    from { top: -50px; opacity: 0; }
    to { top: 20px; opacity: 1; }
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state .icon {
    font-size: 60px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 8px;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-right: 0; padding: 16px; }
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .kpi-row { grid-template-columns: 1fr; }
    .topbar { flex-direction: column; gap: 14px; align-items: flex-start; }
}

/* ===== Approval Timeline ===== */
.timeline {
    position: relative;
    padding-right: 30px;
}

.timeline::before {
    content: "";
    position: absolute;
    right: 14px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 24px;
}

.timeline-item::before {
    content: "";
    position: absolute;
    right: -20px;
    top: 6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--text-light);
}

.timeline-item.done::before { border-color: var(--green); background: var(--green); }
.timeline-item.rejected::before { border-color: var(--red); background: var(--red); }
.timeline-item.current::before {
    border-color: var(--pink);
    background: var(--pink);
    box-shadow: 0 0 0 5px rgba(233,30,99,0.2);
}

.timeline-item .ttl {
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.timeline-item .meta {
    color: var(--text-light);
    font-size: 12px;
    margin-bottom: 6px;
}

.timeline-item .cmt {
    background: var(--bg);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.6;
    margin-top: 6px;
}

/* ===== Stat boxes ===== */
.stat-box {
    background: white;
    border-radius: 14px;
    padding: 16px 20px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-box .ic {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--pink), var(--purple));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-box .info .v {
    font-size: 22px;
    font-weight: 800;
    font-family: 'Tajawal';
}

.stat-box .info .l {
    font-size: 12px;
    color: var(--text-light);
}

.action-btns {
    display: flex;
    gap: 6px;
}
