@font-face {
    font-family: 'IRANSans';
   src: url('../fonts/IRANSansXV.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}
@font-face {
    font-family: 'IRANSans';
    src: url('../fonts/IRANSansXV.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
}
/* Custom Dropdown Styles */
.crm-dropdown-wrap {
    position: relative;
    display: inline-block;
    user-select: none;
    font-family: inherit;
}
.crm-dropdown-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;
    transition: all 0.2s;
    min-width: 140px;
    gap: 8px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.crm-dropdown-selected:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}
.crm-dropdown-selected svg.caret {
    transition: transform 0.2s;
}
.crm-dropdown-wrap.open .crm-dropdown-selected svg.caret {
    transform: rotate(180deg);
}

/* Ensure toolbar fields have same height */
#crm-search,
.crm-toolbar .crm-dropdown-selected {
    height: 46px;
    box-sizing: border-box;
}
.crm-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 100%;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #f3f4f6;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
    overflow: hidden;
    padding: 4px 0;
}
.crm-dropdown-wrap.open .crm-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.crm-dropdown-item {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 0.875rem;
    color: #4b5563;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.crm-dropdown-item:hover {
    background: #f3f4f6;
    color: #111827;
}
.crm-dropdown-item svg {
    flex-shrink: 0;
}

/* Status specific colors */
.status-unread { color: #ef4444 !important; }
.status-in_progress { color: #f59e0b !important; }
.status-done { color: #10b981 !important; }

/* Filter Pills */
.crm-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}
.crm-filter-btn {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    padding: 6px 14px;
    border-radius: 8px; /* Changed to match settings button */
    font-size: 0.875rem;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.crm-filter-btn:hover {
    background: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
}
.crm-filter-btn.active {
    background: #111827;
    color: #fff;
    border-color: #111827;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.crm-filter-btn.clear-filter {
    background: #e5e7eb; /* Gray */
    color: #4b5563;
    border-color: transparent;
}
.crm-filter-btn.clear-filter:hover {
    background: #d1d5db;
    color: #1f2937;
}

.crm-table-container {
    overflow: visible !important;
}

.crm-table th, .crm-table td {
    white-space: nowrap;
}
.crm-table td.message-col {
    white-space: normal;
}

@media (max-width: 768px) {
    .crm-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start !important;
    }
    .crm-toolbar {
        flex-direction: column;
    }
    .crm-table thead {
        display: none;
    }
    .crm-table tbody tr {
        display: flex;
        flex-direction: column;
        background: #fff;
        margin-bottom: 16px;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 16px;
        box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    }
    .crm-header-actions {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px !important;
        width: 100%;
    }
    .crm-header-actions > .sms-credit-widget,
    .crm-header-actions > .crm-dropdown-wrap {
        grid-column: 1 / -1;
        width: 100%;
    }
    .crm-header-actions > button,
    .crm-header-actions > a {
        justify-content: center;
        font-size: 0.75rem !important;
        padding: 6px !important;
    }
    .crm-filters {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        width: 100%;
    }
    .crm-filters .crm-filter-btn {
        width: 100%;
        padding: 6px 4px;
        font-size: 0.7rem;
        justify-content: center;
    }
    .crm-table tbody td {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 16px 0 !important;
        border-bottom: 1px solid #f3f4f6;
    }
    .crm-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6b7280;
        flex-shrink: 0;
        text-align: right;
    }
    .crm-td-val {
        flex: 1;
        display: flex;
        justify-content: flex-end; /* Push content to left in RTL */
        text-align: left;
    }
    /* Special layout for the message column */
    .crm-table tbody td.message-col {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .crm-table tbody td.message-col .crm-td-val {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: flex-start; /* Align content to right in RTL */
        justify-content: flex-start;
        text-align: right;
        gap: 8px;
    }
    .crm-read-tag {
        font-size: 0.65rem !important;
        padding: 3px 8px !important;
    }
    .crm-view-btn {
        font-family: 'IRANSans', Tahoma, Arial, sans-serif !important;
    }
    .crm-table tbody td:last-child {
        border-bottom: none;
    }
    
    .crm-dropdown-wrap {
        width: 100%;
    }
    .crm-table tbody td .crm-dropdown-wrap {
        width: 140px;
    }
    .crm-dropdown-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        top: auto;
        right: auto;
        width: 100%;
        border-radius: 20px 20px 0 0;
        padding: 20px 16px;
        transform: translateY(100%);
        box-shadow: 0 -10px 40px rgba(0,0,0,0.1);
    }
    .crm-dropdown-wrap.open .crm-dropdown-menu {
        transform: translateY(0);
    }
    
    /* Modals Mobile Tweaks */
    #crm-add-user-form,
    #crm-edit-user-form,
    #crm-settings-form > div:first-child,
    #crm-settings-form > div:nth-child(3) > div {
        grid-template-columns: 1fr !important;
    }
    #crm-add-user-form label,
    #crm-edit-user-form label,
    #crm-settings-form label {
        white-space: nowrap !important;
    }
    .checkbox-group {
        flex-direction: column !important;
        gap: 12px !important;
    }
    .crm-table-responsive {
        width: 100%;
        overflow-x: auto;
    }
    .crm-users-table th, .crm-users-table td {
        white-space: nowrap !important;
    }
    .crm-modal-header {
        position: sticky !important;
        top: 0 !important;
        background: #fff !important;
        z-index: 10 !important;
        padding: 20px !important;
        border-bottom: 1px solid #e5e7eb !important;
    }
}
.crm-row:hover {
    background: #f9fafb;
}

/* Hide Scrollbars */
.crm-modal-content {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.crm-modal-content::-webkit-scrollbar {
    display: none;
}

/* Rounded Tables */
.crm-table, .crm-users-table {
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}
.crm-table th, .crm-users-table th {
    background: #f8f9fa;
}
.crm-table th:first-child, .crm-users-table th:first-child {
    border-top-right-radius: 12px;
}
.crm-table th:last-child, .crm-users-table th:last-child {
    border-top-left-radius: 12px;
}
.crm-table tr:last-child td:first-child, .crm-users-table tr:last-child td:first-child {
    border-bottom-right-radius: 12px;
}
.crm-table tr:last-child td:last-child, .crm-users-table tr:last-child td:last-child {
    border-bottom-left-radius: 12px;
}

/* Custom Alert/Confirm Modals */
.crm-alert-box {
    background: #fff;
    padding: 24px;
    border-radius: 16px;
    width: 400px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.crm-alert-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.crm-alert-icon.success { background: #d1fae5; color: #10b981; }
.crm-alert-icon.error { background: #fee2e2; color: #ef4444; }
.crm-alert-icon.confirm { background: #e0e7ff; color: #6366f1; }

/* Read/Unread Tags */
.crm-read-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-left: 0;
    color: #fff;
}
.crm-read-tag.unread {
    background-color: #ea580c; /* Orange */
}
.crm-read-tag.read {
    background-color: #1e40af; /* Darkish Blue */
}


.crm-view-btn { font-family: 'IRANSans', Tahoma, sans-serif !important; }


/* Password input dynamic alignment */
.crm-pass-input { font-family: 'IRANSans', sans-serif !important; text-align: left; direction: ltr; }
.crm-pass-input::placeholder { text-align: right; direction: rtl; font-family: 'IRANSans', sans-serif; }
.crm-pass-input:placeholder-shown { text-align: right; direction: rtl; }


/* Remove black outline and use blue focus border */
.crm-input:focus, .otp-digit:focus, .crm-custom-select:focus, input:focus, textarea:focus, select:focus { outline: none !important; border-color: #1d4ed8 !important; box-shadow: 0 0 0 1px #1d4ed8 !important; }


/* Remove container background on mobile */
@media (max-width: 768px) {
    .crm-table-container {
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
    }
}
