/* ================================================
   Admin Panel - Modern Design System
   ================================================ */

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #F9FAFB;
    color: #111928;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

/* ---- Sidebar ---- */
.ad-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 56px;
    height: 100%;
    background-color: #000;
    border-right: 1px solid rgba(255,255,255,0.08);
    padding: 0 8px;
    z-index: 100;
    transition: .3s ease width, .3s ease padding;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.ad-sidebar.opened {
    width: 220px;
    padding: 0 16px;
}

.ad-sidebar__top {
    padding-top: 16px;
    width: 100%;
    text-align: center;
}

.ad-sidebar__logo {
    margin-bottom: 24px;
    display: flex;
    justify-content: center;
    position: relative;
    height: 32px;
    align-items: center;
}

.ad-sidebar__logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.ad-sidebar__logo-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    transition: .3s ease all;
}

.ad-sidebar__logo-long {
    height: 18px;
    margin-left: 10px;
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    transition: .3s ease all;
}

.ad-sidebar.opened .ad-sidebar__logo-long {
    opacity: 1;
    max-width: 100px;
}

.ad-sidebar__menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ad-sidebar__menu > li {
    margin-bottom: 8px;
}

.ad-sidebar__menu > li > a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    border-radius: 10px;
    color: rgba(255,255,255,0.55);
    transition: background .15s, color .15s;
    white-space: nowrap;
    overflow: hidden;
    padding: 0 8px;
    gap: 0;
}

.ad-sidebar__menu > li > a svg {
    flex-shrink: 0;
}

.ad-sidebar__menu > li > a span {
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    transition: .3s ease all;
    margin-left: 0;
}

.ad-sidebar.opened .ad-sidebar__menu > li > a {
    justify-content: flex-start;
    gap: 12px;
    padding: 0 10px;
}

.ad-sidebar.opened .ad-sidebar__menu > li > a span {
    opacity: 1;
    max-width: 140px;
}

.ad-sidebar__menu > li > a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.ad-sidebar__menu > li > a.current {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

/* Tooltip on collapsed sidebar */
.ad-sidebar:not(.opened) .ad-sidebar__menu > li {
    position: relative;
}

.ad-sidebar:not(.opened) .ad-sidebar__menu > li[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: #1F2937;
    color: #fff;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 200;
}

.ad-sidebar__bottom {
    padding-bottom: 16px;
    display: flex;
    justify-content: center;
}

.ad-sidebar__bottom a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: rgba(255,255,255,0.4);
    transition: background .15s, color .15s;
}

.ad-sidebar__bottom a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.ad-sidebar__bottom svg {
    transition: transform .3s ease;
}

.ad-sidebar.opened .ad-sidebar__bottom svg {
    transform: rotate(180deg);
}

/* ---- Sidebar submenu ---- */
.ad-sidebar__has-sub > a.ad-sidebar__sub-toggle {
    justify-content: center;
}
.ad-sidebar.opened .ad-sidebar__has-sub > a.ad-sidebar__sub-toggle {
    justify-content: flex-start;
}
.ad-sub-arrow { display: none; }
.ad-sidebar.opened .ad-sub-arrow { display: block; }

.ad-sidebar__sub {
    list-style: none;
    padding: 4px 0 4px 0;
    margin: 0;
}
.ad-sidebar__sub li a {
    display: flex;
    align-items: center;
    height: 34px;
    padding: 0 10px 0 20px;
    color: rgba(255,255,255,0.45);
    font-size: 12px;
    font-weight: 500;
    border-radius: 8px;
    transition: background .12s, color .12s;
    white-space: nowrap;
    overflow: hidden;
}
.ad-sidebar__sub li a:hover { color: #fff; background: rgba(255,255,255,0.06); }
.ad-sidebar__sub li a.current { color: #fff; background: rgba(255,255,255,0.1); }

/* Hide sub-menu text when sidebar is collapsed */
.ad-sidebar:not(.opened) .ad-sidebar__sub { display: none !important; }

/* ---- Top header bar ---- */
.ad-header {
    position: fixed;
    top: 0;
    left: 56px;
    right: 0;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 50;
    transition: left .3s ease;
}

.ad-sidebar.opened ~ .ad-main .ad-header,
body.sidebar-open .ad-header {
    left: 220px;
}

.ad-header__title {
    font-size: 16px;
    font-weight: 600;
    color: #111928;
}

.ad-header__right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ad-header__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #1F2937;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ad-header__dropdown {
    position: relative;
}

.ad-header__dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.10);
    min-width: 160px;
    z-index: 200;
    overflow: hidden;
}

.ad-header__dropdown-menu.open {
    display: block;
}

.ad-header__dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    color: #374151;
    font-size: 13px;
    transition: background .12s;
}

.ad-header__dropdown-menu a:hover {
    background: #F9FAFB;
}

/* ---- Main content area ---- */
.ad-main {
    margin-left: 56px;
    padding-top: 56px;
    min-height: 100vh;
    transition: margin-left .3s ease;
}

.ad-sidebar.opened ~ .ad-main {
    margin-left: 220px;
}

.ad-content {
    padding: 28px 32px;
}

/* ---- Page header ---- */
.ad-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.ad-page-title {
    font-size: 20px;
    font-weight: 700;
    color: #111928;
    margin: 0;
}

/* ---- KPI grid ---- */
.ad-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.ad-kpi-card {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 18px 20px;
}

.ad-kpi-card__label {
    font-size: 11px;
    font-weight: 600;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 6px;
}

.ad-kpi-card__value {
    font-size: 26px;
    font-weight: 700;
    color: #111928;
    line-height: 1.1;
}

.ad-kpi-card__sub {
    font-size: 11px;
    color: #9CA3AF;
    margin-top: 3px;
}

/* ---- Card ---- */
.ad-card {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    overflow: hidden;
}

.ad-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #F3F4F6;
    gap: 12px;
    flex-wrap: wrap;
}

.ad-card__title {
    font-size: 14px;
    font-weight: 600;
    color: #111928;
    margin: 0;
}

.ad-card__body {
    padding: 20px;
}

/* ---- Search & filters ---- */
.ad-search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.ad-search-input {
    flex: 1;
    min-width: 220px;
    height: 36px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 0 12px 0 36px;
    font-size: 13px;
    font-family: inherit;
    color: #111928;
    background: #F9FAFB url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 11a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9zm0 1a5.5 5.5 0 1 1 3.89-1.61L13.5 13.5l-.7.7-3.11-3.11A5.48 5.48 0 0 1 6.5 12z' fill='%239CA3AF'/%3E%3C/svg%3E") 10px center no-repeat;
    outline: none;
    transition: border-color .15s;
}

.ad-search-input:focus {
    border-color: #6366F1;
    background-color: #fff;
}

.ad-select {
    height: 36px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 0 10px;
    font-size: 13px;
    font-family: inherit;
    color: #374151;
    background: #fff;
    outline: none;
    cursor: pointer;
}

/* ---- Tabs ---- */
.ad-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #E5E7EB;
    margin-bottom: 20px;
}

.ad-tab {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #6B7280;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}

.ad-tab:hover { color: #374151; }

.ad-tab.active {
    color: #111928;
    border-bottom-color: #111928;
}

.ad-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #F3F4F6;
    color: #6B7280;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    padding: 1px 7px;
    margin-left: 6px;
}

.ad-tab.active .ad-tab-badge {
    background: #1F2937;
    color: #fff;
}

/* ---- Table ---- */
.ad-table-wrap {
    overflow-x: auto;
}

.ad-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.ad-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: .4px;
    border-bottom: 1px solid #F3F4F6;
    white-space: nowrap;
}

.ad-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #F9FAFB;
    color: #374151;
    vertical-align: middle;
}

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

.ad-table tr:hover td { background: #FAFAFA; }

/* ---- Account row ---- */
.ad-acct-name {
    font-weight: 600;
    color: #111928;
    font-size: 13px;
}

.ad-acct-name a {
    color: inherit;
}

.ad-acct-name a:hover {
    color: #6366F1;
}

.ad-acct-email {
    font-size: 12px;
    color: #9CA3AF;
    margin-top: 2px;
}

/* ---- Badges / tags ---- */
.ad-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.ad-badge--active   { background: #ECFDF5; color: #059669; }
.ad-badge--trialing { background: #FFFBEB; color: #D97706; }
.ad-badge--past_due { background: #FEF2F2; color: #DC2626; }
.ad-badge--canceled { background: #F3F4F6; color: #6B7280; }
.ad-badge--default  { background: #EEF2FF; color: #4F46E5; }
.ad-badge--gray     { background: #F3F4F6; color: #6B7280; }

/* ---- Buttons ---- */
.ad-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
    text-decoration: none;
}

.ad-btn--primary {
    background: #111928;
    color: #fff;
}

.ad-btn--primary:hover { background: #1F2937; color: #fff; }

.ad-btn--outline {
    background: #fff;
    color: #374151;
    border: 1px solid #E5E7EB;
}

.ad-btn--outline:hover { background: #F9FAFB; }

.ad-btn--danger {
    background: #FEF2F2;
    color: #DC2626;
    border: 1px solid #FECACA;
}

.ad-btn--danger:hover { background: #FEE2E2; }

.ad-btn--sm {
    height: 30px;
    padding: 0 12px;
    font-size: 12px;
}

/* ---- Pagination ---- */
.ad-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-top: 1px solid #F3F4F6;
    font-size: 13px;
    color: #6B7280;
    flex-wrap: wrap;
    gap: 10px;
}

.ad-pagination__pages {
    display: flex;
    gap: 4px;
}

.ad-pagination__btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid #E5E7EB;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    color: #374151;
    transition: background .12s;
}

.ad-pagination__btn:hover { background: #F9FAFB; }
.ad-pagination__btn.active { background: #111928; color: #fff; border-color: #111928; }

/* ---- Modal ---- */
.ad-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ad-modal-overlay.open {
    display: flex;
}

.ad-modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.ad-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #F3F4F6;
}

.ad-modal__title {
    font-size: 16px;
    font-weight: 600;
    color: #111928;
    margin: 0;
}

.ad-modal__close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: none;
    background: none;
    cursor: pointer;
    color: #9CA3AF;
    transition: background .12s, color .12s;
}

.ad-modal__close:hover { background: #F3F4F6; color: #374151; }

.ad-modal__body {
    padding: 20px 24px;
}

.ad-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px 20px;
    border-top: 1px solid #F3F4F6;
}

/* ---- Form fields ---- */
.ad-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

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

.ad-form-group:last-child { margin-bottom: 0; }

.ad-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.ad-input {
    width: 100%;
    height: 36px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 13px;
    font-family: inherit;
    color: #111928;
    background: #fff;
    outline: none;
    transition: border-color .15s;
}

.ad-input:focus { border-color: #6366F1; }

.ad-input--error { border-color: #DC2626; }

.ad-error-msg {
    font-size: 12px;
    color: #DC2626;
    margin-top: 4px;
    display: none;
}

.ad-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #F9FAFB;
}

.ad-toggle-row:last-child { border-bottom: none; }

.ad-toggle-label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

.ad-toggle-sub {
    font-size: 11px;
    color: #9CA3AF;
    margin-top: 2px;
}

/* ---- Toggle switch ---- */
.ad-switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    flex-shrink: 0;
}

.ad-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.ad-switch__slider {
    position: absolute;
    inset: 0;
    background: #9CA3AF;
    border-radius: 22px;
    cursor: pointer;
    transition: background .2s;
    border: 1px solid rgba(0,0,0,.08);
    display: flex;
    align-items: center;
}

.ad-switch__slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    /* top: 3px; */
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.ad-switch input:checked ~ .ad-switch__slider {
    background: #111928;
}

.ad-switch input:checked ~ .ad-switch__slider::before {
    transform: translateX(16px);
}

/* ---- Alert ---- */
.ad-alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.ad-alert--success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.ad-alert--error   { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }

/* ---- Bootstrap modal compatibility (quotes page) ---- */
.modal-backdrop { z-index: 498; }
.modal { z-index: 499; }
.modal .modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 13px;
}
.modal .modal-header { border-bottom: 1px solid #F3F4F6; padding: 16px 20px; }
.modal .modal-title { font-size: 16px; font-weight: 600; color: #111928; }
.modal .modal-body  { padding: 20px; }
.modal .modal-footer { border-top: 1px solid #F3F4F6; padding: 12px 20px; }
.modal .form-control {
    height: 36px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 13px;
    font-family: inherit;
}
.modal .form-group { margin-bottom: 14px; }
.modal .form-group label { font-size: 12px; font-weight: 600; color: #374151; }
.modal .btn-primary { background: #111928; border-color: #111928; border-radius: 8px; }
.modal .btn-default { background: #fff; border-color: #E5E7EB; color: #374151; border-radius: 8px; }

/* AJAX-rendered table rows from old JS (use basic styling) */
#allcontactTBody tr td { padding: 12px 14px; border-bottom: 1px solid #F9FAFB; color: #374151; vertical-align: middle; font-size: 13px; }
#allcontactTBody tr:hover td { background: #FAFAFA; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .ad-content { padding: 20px 16px; }
    .ad-kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .ad-form-row { grid-template-columns: 1fr; }
}
