/* Pharmacy Customer Management System - Mobile-first RTL styles */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

:root {
    --color-primary: #1f9d76;
    --color-primary-dark: #17805f;
    --color-primary-light: #e6f6f1;
    --color-danger: #e0473f;
    --color-danger-dark: #c23a33;
    --color-text: #1f2a2e;
    --color-text-light: #66767a;
    --color-border: #e2e8e6;
    --color-bg: #f5f8f7;
    --color-card: #ffffff;
    --radius: 14px;
    --shadow: 0 2px 10px rgba(20, 40, 35, 0.06);
    --shadow-md: 0 6px 24px rgba(20, 40, 35, 0.12);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', 'Tajawal', Tahoma, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

button {
    font-family: inherit;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.05s ease, opacity 0.15s ease;
    min-height: 44px;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

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

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

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

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--color-danger-dark);
}

.btn-logout {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    padding: 8px 14px;
    font-size: 14px;
    min-height: 36px;
}

.btn-sm {
    padding: 9px 10px;
    font-size: 13px;
    min-height: 40px;
}

.btn-whatsapp {
    background: #e9f9f0;
    color: #1a9e57;
}

.btn-call {
    background: #e8f1fb;
    color: #1a6fbf;
}

.btn-edit {
    background: #fff5e6;
    color: #b3720a;
}

.btn-delete {
    background: #fdeceb;
    color: var(--color-danger-dark);
}

/* ---------- Header ---------- */

.app-header {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: var(--shadow);
}

.app-title {
    font-size: 19px;
    font-weight: 800;
    margin: 0;
}

/* ---------- Dashboard layout ---------- */

.dashboard {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 48px;
}

.stats-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 14px;
}

.stats-label {
    color: var(--color-text-light);
    font-size: 14px;
    font-weight: 600;
}

.stats-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--color-primary-dark);
}

.action-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.btn-add {
    font-size: 16px;
}

.export-buttons {
    display: flex;
    gap: 10px;
}

.export-buttons .btn {
    flex: 1;
}

/* ---------- Search ---------- */

.search-wrapper {
    position: relative;
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 13px 44px 13px 16px;
    font-size: 15px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: #fff;
    font-family: inherit;
    min-height: 48px;
}

.search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.search-spinner {
    position: absolute;
    inset-inline-start: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* ---------- Alerts ---------- */

.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 14px;
}

.alert-error {
    background: #fdeceb;
    color: var(--color-danger-dark);
}

.alert-success {
    background: #e6f6f1;
    color: var(--color-primary-dark);
}

.alert-fixed {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    min-width: 260px;
    max-width: 92vw;
    text-align: center;
    box-shadow: var(--shadow-md);
}

/* ---------- Customer list ---------- */

.customers-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-state {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px 20px;
    text-align: center;
    color: var(--color-text-light);
}

.empty-state-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 6px;
}

.empty-state .btn {
    margin-top: 16px;
}

.no-results {
    text-align: center;
    padding: 30px 10px;
    color: var(--color-text-light);
    font-weight: 600;
}

/* ---------- Pagination ---------- */

.pagination[hidden] {
    display: none;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
}

.pagination-info {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-light);
    white-space: nowrap;
}

.pagination .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile cards */

.customer-card {
    background: var(--color-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}

.customer-card-name {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 6px;
}

.customer-card-line {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--color-text-light);
    font-size: 14px;
    margin-bottom: 3px;
}

.customer-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 14px;
}

/* Desktop table (hidden on mobile) */

.customers-table-wrapper {
    display: none;
}

.customers-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.customers-table th,
.customers-table td {
    padding: 12px 14px;
    text-align: right;
    border-bottom: 1px solid var(--color-border);
    font-size: 14px;
}

.customers-table th {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    font-weight: 700;
}

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

.table-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ---------- Modal ---------- */

.modal-overlay[hidden] {
    display: none;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 25, 22, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 50;
    padding: 0;
}

.modal {
    background: #fff;
    border-radius: 18px 18px 0 0;
    padding: 20px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.modal-small {
    border-radius: 18px;
    margin: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-header h2 {
    font-size: 18px;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--color-text-light);
    padding: 6px;
    line-height: 1;
}

.confirm-text {
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    margin: 10px 0 20px;
}

.confirm-actions {
    display: flex;
    gap: 10px;
}

.confirm-actions .btn {
    flex: 1;
}

/* ---------- Forms ---------- */

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    font-family: inherit;
    min-height: 46px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.field-error {
    display: block;
    color: var(--color-danger-dark);
    font-size: 13px;
    margin-top: 4px;
    min-height: 16px;
}

/* ---------- Login page ---------- */

.login-page {
    background: linear-gradient(160deg, var(--color-primary), var(--color-primary-dark));
    min-height: 100vh;
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
}

.login-title {
    text-align: center;
    font-size: 24px;
    margin: 0 0 4px;
}

.login-subtitle {
    text-align: center;
    color: var(--color-text-light);
    font-size: 14px;
    margin: 0 0 24px;
}

.login-form .btn {
    margin-top: 6px;
}

/* ---------- Tablet / Desktop ---------- */

@media (min-width: 640px) {
    .action-row {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .export-buttons {
        width: auto;
    }

    .customer-card-actions {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 860px) {
    .dashboard {
        padding: 24px;
    }

    .customers-container .customer-card {
        display: none;
    }

    .customers-table-wrapper {
        display: block;
        overflow-x: auto;
    }

    .modal-overlay {
        align-items: center;
    }

    .modal {
        border-radius: var(--radius);
    }
}
