/* Copyright (C) 2025 - KSI 30 <contact@ksi30.fr>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 */
.badge-userremain{background:#0d47a1;color:#fff;border-radius:8px;padding:2px 6px}

.fichecenter.sendsms-form-wrapper{width:100%;max-width:none}
.sendsms-form table{width:100%;table-layout:fixed}
.sendsms-edit-table col.sendsms-col-thirdparty{width:18%}
.sendsms-edit-table col.sendsms-col-phone{width:18%}
.sendsms-edit-table col.sendsms-col-preview{width:64%}
@media (max-width:768px){
  .sendsms-edit-table col.sendsms-col-thirdparty,
  .sendsms-edit-table col.sendsms-col-phone,
  .sendsms-edit-table col.sendsms-col-preview{width:auto}
}
.sendsms-form td{vertical-align:top}
.sendsms-form input[type="text"],.sendsms-form textarea{width:100%;max-width:100%;box-sizing:border-box}
.sendsms-message-cell{width:100%}
.sendsms-message-input{width:100%}

.sendsms-quota-alert{position:fixed;top:90px;right:24px;z-index:4200;min-width:260px;max-width:360px;padding:12px 16px;border-radius:6px;box-shadow:0 6px 18px rgba(0,0,0,.18);color:#fff;font-weight:600;font-size:.95rem;line-height:1.35;display:flex;align-items:flex-start;gap:0.5rem}
.sendsms-quota-alert:before{content:"\26A0";font-size:1.1rem;line-height:1}
.sendsms-quota-alert[data-auto-hide="1"]{transition:opacity .25s ease,transform .25s ease;transform:translateY(-6px);opacity:0}
.sendsms-quota-alert[data-auto-hide="1"].is-active{opacity:1;transform:translateY(0)}
.sendsms-quota-alert[data-auto-hide="1"].is-dismissed{opacity:0;transform:translateY(-6px);pointer-events:none}
.sendsms-quota-alert a{color:inherit;text-decoration:underline;font-weight:700}
.sendsms-quota-alert-low{background:#fb8c00}
.sendsms-quota-alert-empty{background:#e53935}

/* Simulated FontAwesome ksi icon */
.fa-ksi:before,.fa.fa-ksi:before,.fas.fa-ksi:before{content:'\f7cd';font-family:'Font Awesome 5 Free';font-weight:900}

.sendsms-message-cell{vertical-align:top}
.sendsms-template-select{display:flex;align-items:center;gap:0.5rem;margin-bottom:0.5rem;flex-wrap:wrap}
.sendsms-template-select label{font-weight:600;flex:0 0 auto}
.sendsms-template-select select{min-width:220px;flex:1 1 220px}
.sendsms-template-select .button.smallbutton{padding:4px 10px}
.sendsms-sender-field{margin-top:0.75rem;display:flex;flex-direction:column;gap:0.35rem}
.sendsms-sender-field label{font-weight:600}
.sendsms-sender-field input{max-width:260px}
.sendsms-options-grid{margin-top:0.75rem;display:flex;flex-wrap:wrap;gap:1rem;align-items:flex-end}
.sendsms-option{display:flex;flex-direction:column;gap:0.3rem;min-width:160px}
.sendsms-option label{font-weight:600}
.sendsms-option select,.sendsms-option input{min-width:140px}
.sendsms-option-checkbox{min-width:auto}
.sendsms-option-checkbox .sendsms-switch{gap:0.5rem}
.sendsms-option-checkbox .sendsms-switch-text{font-weight:600}
.sendsms-option-checkbox .sendsms-switch input{position:absolute;opacity:0;pointer-events:none}
.sendsms-option-checkbox .sendsms-switch .sendsms-switch-slider{position:relative;display:inline-block;width:42px;height:22px;background:#c4c4c4;border-radius:12px;transition:background .2s ease}
.sendsms-option-checkbox .sendsms-switch .sendsms-switch-slider:after{content:"";position:absolute;top:2px;left:2px;width:18px;height:18px;border-radius:50%;background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.2);transition:transform .2s ease}
.sendsms-option-checkbox .sendsms-switch input:checked+.sendsms-switch-slider{background:#2e7d32}
.sendsms-option-checkbox .sendsms-switch input:checked+.sendsms-switch-slider:after{transform:translateX(20px)}
.sendsms-counter{margin-top:0.4rem;font-size:0.9rem;color:#555}
.sendsms-test-toggle{display:flex;align-items:center;gap:0.6rem;margin-top:0.6rem}
.sendsms-test-toggle .sendsms-switch{display:inline-flex;align-items:center;gap:0.4rem;cursor:pointer}
.sendsms-test-toggle .sendsms-switch input{position:absolute;opacity:0;pointer-events:none}
.sendsms-test-toggle .sendsms-switch .sendsms-switch-slider{position:relative;display:inline-block;width:42px;height:22px;background:#c4c4c4;border-radius:12px;transition:background .2s ease}
.sendsms-test-toggle .sendsms-switch .sendsms-switch-slider:after{content:"";position:absolute;top:2px;left:2px;width:18px;height:18px;border-radius:50%;background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.2);transition:transform .2s ease}
.sendsms-test-toggle .sendsms-switch input:checked+.sendsms-switch-slider{background:#2e7d32}
.sendsms-test-toggle .sendsms-switch input:checked+.sendsms-switch-slider:after{transform:translateX(20px)}
.sendsms-test-toggle .sendsms-switch-text{font-weight:600}
.sendsms-test-toggle .sendsms-test-help{font-size:0.85rem;color:#666}
.sendsms-preview{margin-top:0.6rem;background:#f7f7f7;border:1px solid #ddd;border-radius:4px;padding:0.6rem}
.sendsms-preview pre,.sendsms-preview .sendsms-preview-message{margin:0;white-space:pre-wrap;word-break:break-word;font-family:inherit}
.sendsms-message-cell details{margin-top:0.6rem}
.sendsms-message-meta{margin-top:0.35rem;font-size:0.85rem;color:#555}
.sendsms-test-result{margin-top:0.6rem;border:1px solid #e0e0e0;border-radius:4px;padding:0.6rem;background:#fff8e1}
.sendsms-test-result strong{display:block;margin-bottom:0.35rem}
.sendsms-test-meta{font-size:0.85rem;color:#555}
.sendsms-test-result-body{margin-top:0.4rem;white-space:pre-wrap;word-break:break-word;font-family:inherit}
.sendsms-template-raw{display:block;margin-top:0.6rem}
.sendsms-template-raw pre{margin:0;white-space:pre-wrap;word-break:break-word;font-family:monospace;font-size:0.9rem}
.sendsms-substitutions{display:block;margin-top:0.6rem}
.sendsms-substitutions table{width:100%}
.sendsms-template-form{margin-top:1rem}
.sendsms-template-form table td{padding:6px}
.sendsms-test-mode{margin-top:1rem;border:1px solid #ddd;border-radius:6px;padding:0.8rem;background:#fafafa}
.sendsms-test-mode legend{font-weight:600}
.sendsms-test-row{display:flex;align-items:center;gap:0.6rem;margin-bottom:0.5rem}
.sendsms-test-row label{min-width:160px;font-weight:600}
.sendsms-test-row input[type="number"],.sendsms-test-row select{min-width:150px}
.sendsms-test-actions{display:flex;justify-content:flex-start}
.sendsms-form-actions{margin-top:1rem}
.sendsms-history-filters{margin:1rem 0;display:flex;flex-wrap:wrap;gap:0.75rem;align-items:flex-end}
.sendsms-history-filters .form-element{display:flex;flex-direction:column;gap:0.25rem}
.sendsms-history-filters label{font-weight:600}
.sendsms-history-table{margin-top:1rem}
.sendsms-history-table td,.sendsms-history-table th{padding:6px}
.sendsms-history-actions form{display:inline-block;margin:0}
.sendsms-history-actions .button{margin:0}
.sendsms-history-status{display:inline-flex;align-items:center;gap:0.35rem;font-size:0.9rem;font-weight:600;text-transform:uppercase;border-radius:12px;padding:2px 8px}
.sendsms-status-new{background:#ede7f6;color:#4527a0}
.sendsms-status-queued{background:#e3f2fd;color:#1565c0}
.sendsms-status-sent{background:#e8f5e9;color:#2e7d32}
.sendsms-status-failed{background:#ffebee;color:#c62828}
.sendsms-status-test{background:#fff3e0;color:#ef6c00}


/* Hero wrapper for embedded SMS form */
.sendsms-hero-wrapper {
    margin: 12px 0 18px 0;
    padding: 14px 16px 18px 16px;
    background: #f5f7fb;
    border: 1px solid #d6d9e4;
    border-radius: 6px;
}
.sendsms-hero-wrapper--modal {
    margin: 0;
    border: none;
    background: transparent;
    padding: 0;
}

/* Page hero for sendsms pages */
.sendsms-page-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    margin: 0 0 12px 0;
    background: linear-gradient(135deg, #f5f7fb 0%, #e8eef8 60%, #dfe7f5 100%);
    border: 1px solid #d6d9e4;
    border-radius: 6px;
}
.sendsms-page-hero__icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--colorbackhmenu1, #22437a);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}
.sendsms-page-hero__title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: #1f2d3d;
}
.sendsms-page-hero__subtitle {
    margin: 2px 0 0 0;
    color: #3f4d63;
    font-size: 0.95rem;
}
.sendsms-actions-bar {
    margin: 12px 0;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Dolibarr-like action button inside modal/embedded pages */
.sendsms-modal .butAction,
.sendsms-inline-wrapper .butAction,
.sendsms-form .butAction {
    background: var(--butactionbg, #966ea2);
    border: 1px solid var(--butactionbg, #966ea2);
    color: #fff !important;
    border-radius: 4px;
    padding: 6px 12px;
    font-weight: 600;
    text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.sendsms-modal .butAction:hover,
.sendsms-inline-wrapper .butAction:hover,
.sendsms-form .butAction:hover {
    background: var(--butactionbg, #966ea2);
    filter: brightness(1.05);
}
.sendsms-modal .butAction:active,
.sendsms-inline-wrapper .butAction:active,
.sendsms-form .butAction:active {
    transform: translateY(1px);
}

/* Inline placement under action buttons */
.sendsms-inline-wrapper {
    width: 100%;
    clear: both;
    display: block;
    margin-top: 8px;
}

/* Modal for inline SMS form */
.sendsms-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 6000;
}
.sendsms-modal.is-open { display: flex; }
.sendsms-modal__backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
}
.sendsms-modal__dialog {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    max-width: 960px;
    width: 95%;
    min-width: 360px;
    height: 80vh;
    max-height: 90vh;
    min-height: 260px;
    padding: 16px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;
}
.sendsms-modal__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 12px 12px;
    margin: -16px -16px 12px -16px;
    border-radius: 6px 6px 0 0;
    background: linear-gradient(135deg, var(--colorbackhmenu1, #22437a) 0%, var(--colorbackhmenu1, #22437a) 65%, #1b2b46 100%);
    color: #fff;
    padding-right: 92px;
    cursor: move;
    user-select: none;
}
.sendsms-modal__icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255,255,255,0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    letter-spacing: 0.5px;
    font-size: 0.9rem;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
}
.sendsms-modal__title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}
.sendsms-modal__subtitle {
    margin: 2px 0 0 0;
    opacity: 0.85;
    font-size: 0.95rem;
}
.sendsms-modal__controls {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    z-index: 2;
}
.sendsms-modal__btn {
    width: 30px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.14);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.sendsms-modal__btn:hover {
    background: rgba(255,255,255,0.22);
}
.sendsms-modal__btn:active {
    transform: translateY(1px);
}
.sendsms-modal__btn:focus {
    outline: 2px solid rgba(255,255,255,0.5);
    outline-offset: 1px;
}
.sendsms-modal__close {
    font-size: 18px;
}
.sendsms-modal__minimize {
    font-size: 14px;
}
.sendsms-modal__resize-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    right: 6px;
    bottom: 6px;
    border-right: 2px solid #c1c7d0;
    border-bottom: 2px solid #c1c7d0;
    cursor: se-resize;
    opacity: 0.7;
}
.sendsms-modal__resize-handle:hover {
    opacity: 1;
}
.sendsms-inline-wrapper {
    width: 100%;
    clear: both;
    display: block;
    margin-top: 8px;
}
.sendsms-modal .sendsms-inline-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    overflow: auto;
}
.sendsms-modal .sendsms-inline-wrapper iframe {
    flex: 1 1 auto;
    width: 100%;
    border: 0;
}
.sendsms-modal.is-dragging .sendsms-modal__dialog {
    user-select: none;
}
.sendsms-modal.is-minimized {
    display: block;
    align-items: flex-end;
    justify-content: flex-end;
    pointer-events: none;
}
.sendsms-modal.is-minimized .sendsms-modal__backdrop {
    display: none;
}
.sendsms-modal.is-minimized .sendsms-modal__dialog {
    left: auto;
    top: auto;
    right: 12px;
    bottom: 12px;
    transform: none;
    width: 360px;
    max-width: 480px;
    height: auto;
    min-height: 0;
    resize: none;
    cursor: move;
    padding: 12px 14px 14px 14px;
    pointer-events: auto;
}
.sendsms-modal.is-minimized .sendsms-modal__header {
    margin-bottom: 4px;
    padding: 8px 12px 10px 12px;
}
.sendsms-modal.is-minimized .sendsms-inline-wrapper {
    display: none;
}
