@tailwind base;
@tailwind components;
@tailwind utilities;

/* =========================================================
   EMAIL MANAGER ADMIN UI
   ========================================================= */

:root {
    --em-bg: #f3f6fb;
    --em-card: #ffffff;
    --em-border: #e2e8f0;
    --em-text: #0f172a;
    --em-muted: #64748b;

    --em-primary: #2563eb;
    --em-primary-hover: #1d4ed8;

    --em-success: #16a34a;
    --em-success-hover: #15803d;

    --em-warning: #d97706;
    --em-warning-hover: #b45309;

    --em-danger: #dc2626;
    --em-danger-hover: #b91c1c;

    --em-radius: 12px;

    --em-shadow:
        0 1px 2px rgba(15, 23, 42, 0.04),
        0 6px 20px rgba(15, 23, 42, 0.05);
}

/* ---------------------------------------------------------
   GLOBAL
   --------------------------------------------------------- */

body {
    background: var(--em-bg);
    color: var(--em-text);
}

.em-page {
    width: 100%;
    max-width: 1450px;
    margin: 0 auto;
    padding: 28px 24px 60px;
}

.em-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.em-page-title {
    margin: 0;
    font-size: 1.6rem;
    line-height: 1.25;
    font-weight: 700;
    color: var(--em-text);
}

.em-page-subtitle {
    margin-top: 5px;
    color: var(--em-muted);
    font-size: 0.9rem;
}

/* ---------------------------------------------------------
   CARDS
   --------------------------------------------------------- */

.em-card {
    margin-bottom: 22px;
    background: var(--em-card);
    border: 1px solid var(--em-border);
    border-radius: var(--em-radius);
    box-shadow: var(--em-shadow);
    overflow: hidden;
}

.em-card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--em-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.em-card-body {
    padding: 22px;
}

.em-card-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--em-text);
}

.em-card-description {
    margin-top: 4px;
    color: var(--em-muted);
    font-size: 0.875rem;
}

/* ---------------------------------------------------------
   INFO GRID
   --------------------------------------------------------- */

.em-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 30px;
}

.em-info-label {
    color: var(--em-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.em-info-value {
    margin-top: 4px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--em-text);
}

/* ---------------------------------------------------------
   STATS
   --------------------------------------------------------- */

.em-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.em-stat-card {
    background: #fff;
    border: 1px solid var(--em-border);
    border-radius: var(--em-radius);
    padding: 18px 20px;
    box-shadow: var(--em-shadow);
}

.em-stat-label {
    color: var(--em-muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.em-stat-number {
    margin-top: 8px;
    font-size: 1.9rem;
    line-height: 1;
    font-weight: 750;
    color: var(--em-text);
}

/* ---------------------------------------------------------
   STATUS BADGES
   --------------------------------------------------------- */

.em-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 0.76rem;
    line-height: 1.2;
    font-weight: 700;
    white-space: nowrap;
}

.em-status-draft {
    background: #f1f5f9;
    color: #475569;
}

.em-status-queued {
    background: #fef3c7;
    color: #92400e;
}

.em-status-sending {
    background: #dbeafe;
    color: #1d4ed8;
}

.em-status-completed {
    background: #dcfce7;
    color: #166534;
}

.em-status-failed {
    background: #fee2e2;
    color: #991b1b;
}

.em-status-pending {
    background: #fef3c7;
    color: #92400e;
}

.em-status-sent {
    background: #dcfce7;
    color: #166534;
}

/* ---------------------------------------------------------
   ALERTS
   --------------------------------------------------------- */

.em-alert {
    margin-bottom: 20px;
    padding: 14px 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 0.9rem;
}

.em-alert-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.em-alert-danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.em-alert-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

/* ---------------------------------------------------------
   LOCK NOTICE
   --------------------------------------------------------- */

.em-locked {
    margin-bottom: 22px;
    padding: 15px 17px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    color: #92400e;
}

/* ---------------------------------------------------------
   BUTTONS
   --------------------------------------------------------- */

.em-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
}

.em-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 9px 15px;

    border: 1px solid transparent;
    border-radius: 9px;

    font-size: 0.875rem;
    font-weight: 650;
    line-height: 1;

    cursor: pointer;
    text-decoration: none;

    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.1s ease;
}

.em-btn:hover {
    transform: translateY(-1px);
}

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

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

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

.em-btn-success:hover {
    background: var(--em-success-hover);
}

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

.em-btn-warning:hover {
    background: var(--em-warning-hover);
}

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

.em-btn-danger:hover {
    background: #fef2f2;
}

.em-btn-dark {
    background: #1e293b;
    color: #fff;
}

.em-btn-dark:hover {
    background: #0f172a;
}

.em-btn-secondary {
    background: #fff;
    color: #334155;
    border-color: #cbd5e1;
}

.em-btn-secondary:hover {
    background: #f8fafc;
}

/* ---------------------------------------------------------
   FORMS
   --------------------------------------------------------- */

.em-filter-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

.em-label {
    display: block;
    margin-bottom: 6px;
    color: #334155;
    font-size: 0.82rem;
    font-weight: 650;
}

.em-input,
.em-select,
.em-textarea {
    display: block;
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;

    border: 1px solid #cbd5e1;
    border-radius: 9px;

    background: #fff;
    color: var(--em-text);

    font-size: 0.9rem;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.em-textarea {
    min-height: 100px;
}

.em-input:focus,
.em-select:focus,
.em-textarea:focus {
    border-color: #60a5fa;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.em-input:disabled,
.em-select:disabled,
.em-textarea:disabled {
    background: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
}

/* ---------------------------------------------------------
   TABLE
   --------------------------------------------------------- */

.em-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--em-border);
    border-radius: 10px;
}

.em-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.em-table th {
    padding: 11px 14px;

    background: #f8fafc;
    border-bottom: 1px solid var(--em-border);

    color: #475569;

    font-size: 0.73rem;
    font-weight: 700;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.04em;

    white-space: nowrap;
}

.em-table td {
    padding: 13px 14px;

    border-bottom: 1px solid #edf2f7;

    font-size: 0.875rem;
    color: #334155;
    vertical-align: middle;
}

.em-table tbody tr:hover {
    background: #f8fbff;
}

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

.em-error-text {
    color: #b91c1c !important;
    max-width: 420px;
    word-break: break-word;
}

/* ---------------------------------------------------------
   SEND PANELS
   --------------------------------------------------------- */

.em-send-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.em-send-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--em-text);
}

.em-send-description {
    margin-top: 4px;
    color: var(--em-muted);
    font-size: 0.875rem;
}

/* ---------------------------------------------------------
   ACTIVITY TIMELINE
   --------------------------------------------------------- */

.em-activity-item {
    position: relative;
    margin-left: 5px;
    padding: 0 0 22px 25px;
    border-left: 2px solid #e2e8f0;
}

.em-activity-item:last-child {
    padding-bottom: 0;
}

.em-activity-item::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 4px;

    width: 10px;
    height: 10px;

    background: #2563eb;
    border: 2px solid #fff;
    border-radius: 50%;

    box-shadow: 0 0 0 1px #bfdbfe;
}

.em-activity-user {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--em-text);
}

.em-activity-description {
    margin-top: 3px;
    color: #475569;
    font-size: 0.875rem;
}

.em-activity-time {
    margin-top: 4px;
    color: #94a3b8;
    font-size: 0.75rem;
}

/* ---------------------------------------------------------
   SUMMERNOTE
   --------------------------------------------------------- */

.note-editor.note-frame {
    border: 1px solid #cbd5e1 !important;
    border-radius: 10px !important;
    overflow: hidden;
}

.note-editor .note-toolbar {
    background: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

.note-editor .note-editing-area .note-editable {
    min-height: 350px;
    padding: 18px !important;
    background: #fff;
}

/* ---------------------------------------------------------
   RESPONSIVE
   --------------------------------------------------------- */

@media (max-width: 1000px) {
    .em-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .em-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .em-page {
        padding: 18px 14px 40px;
    }

    .em-page-header,
    .em-send-box {
        align-items: flex-start;
        flex-direction: column;
    }

    .em-info-grid,
    .em-stats,
    .em-filter-grid {
        grid-template-columns: 1fr;
    }

    .em-card-body,
    .em-card-header {
        padding: 16px;
    }

    .em-stat-number {
        font-size: 1.6rem;
    }
}


/* =========================================================
   USER FORM
   ========================================================= */

.mb-3 {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #334155;
}

.form-control,
.form-select {
    display: block;
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;

    background: #ffffff;
    color: #0f172a;

    border: 1px solid #cbd5e1;
    border-radius: 9px;

    font-size: 0.9rem;
    line-height: 1.4;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        background-color 0.15s ease;
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.form-control::placeholder {
    color: #94a3b8;
}

.form-control:disabled,
.form-select:disabled {
    background: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
}

.form-select {
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, #64748b 50%),
        linear-gradient(135deg, #64748b 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 50%,
        calc(100% - 13px) 50%;
    background-size:
        5px 5px,
        5px 5px;
    background-repeat: no-repeat;

    padding-right: 38px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-check-input {
    width: 18px;
    height: 18px;
    margin: 0;

    border: 1px solid #cbd5e1;
    border-radius: 4px;

    cursor: pointer;
}

.form-check-input:checked {
    accent-color: #2563eb;
}

.form-check-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
}

.form-text {
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: #64748b;
}

.invalid-feedback {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: #dc2626;
}

.form-control.is-invalid,
.form-select.is-invalid {
    border-color: #dc2626;
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

/* Summernote list fix */
.note-editable ul {
    list-style-type: disc !important;
    padding-left: 2rem !important;
    margin: 0.75rem 0 !important;
}

.note-editable ol {
    list-style-type: decimal !important;
    padding-left: 2rem !important;
    margin: 0.75rem 0 !important;
}

.note-editable ul ul {
    list-style-type: circle !important;
}

.note-editable ul ul ul {
    list-style-type: square !important;
}

.note-editable li {
    display: list-item !important;
}