/* ====================== */
/* M365 Tenant Checker Styles - All-In-One CSS */
/* ====================== */

/* ----- Base Layout ----- */
.m365-tenant-checker-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ----- Search Form ----- */
.m365-search-section {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.m365-search-form .form-row {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

/* Responsive Input Group */
.input-group {
    flex: 2;
    min-width: 200px;
    position: relative;
}
.tenant-input {
    width: 100%;
    padding: 12px 15px;
    padding-right: 160px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 16px;
    height: 48px;
    box-sizing: border-box;
    transition: border-color 0.3s ease;
}
.tenant-input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}
.input-suffix {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
    white-space: nowrap;
    background: #fff;
    padding: 2px 4px;
    border-radius: 3px;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Dynamic suffix sizing for different viewports */
@media (max-width: 1200px) {
    .tenant-input { padding-right: 140px !important; }
    .input-suffix { font-size: 13px; max-width: 120px; right: 12px; }
}
@media (max-width: 992px) {
    .tenant-input { padding-right: 130px !important; }
    .input-suffix { font-size: 12px; max-width: 110px; right: 10px; }
}
.tenant-input:focus + .input-suffix {
    color: #0066cc;
    font-weight: 600;
    background: rgba(0,102,204,0.05);
    border: 1px solid rgba(0,102,204,0.2);
}
/* Hide suffix for domain mode */
.input-suffix.hidden { display: none; }
.input-suffix.hidden + .tenant-input,
.tenant-input.domain-mode { padding-right: 15px !important; }
.tenant-input::placeholder {
    color: #6c757d;
    opacity: 0.8;
    font-size: 14px;
    padding-right: 10px;
}
@media (max-width: 400px) {
    .tenant-input::placeholder { padding-right: 0; font-size: 15px; }
}
@media (min-resolution: 150dpi) and (max-width: 800px) {
    .tenant-input { padding-right: 120px !important; }
    .input-suffix { font-size: 11px; max-width: 100px; }
}
@media (min-resolution: 200dpi) {
    .input-suffix {
        font-size: 12px;
        font-weight: 600;
        background: rgba(255,255,255,0.9);
        border: 1px solid #e9ecef;
    }
}

/* ----- Custom Dropdown (Region Select) ----- */
.custom-select-wrapper {
    position: relative;
    width: 100%;
    min-width: 160px;
}
.custom-select { width: 100%; position: relative; }
.select-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 16px;
    height: 48px;
    background: #fff;
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color 0.3s ease;
    min-width: 160px;
}
.select-display:hover { border-color: #0066cc; }
.select-display.active {
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
}
.selected-text { color: #2c3e50; white-space: nowrap; }
.select-arrow { color: #6c757d; font-size: 12px; transition: transform 0.3s ease; margin-left: 10px; }
.select-display.active .select-arrow { transform: rotate(180deg); }
.select-options {
    position: absolute; top: 100%; left: 0; right: 0;
    background: #fff; border: 2px solid #0066cc; border-top: none;
    border-radius: 0 0 8px 8px; box-shadow: 0 4px 12px rgba(0,102,204,0.15);
    z-index: 1000; max-height: 200px; overflow-y: auto; min-width: 160px; width: auto;
}
.select-option {
    padding: 12px 15px; cursor: pointer; transition: background 0.2s;
    font-size: 16px; border-bottom: 1px solid #f0f0f0;
    white-space: nowrap; min-width: 140px;
}
.select-option:last-child { border-bottom: none; }
.select-option:hover { background: #f8f9fa; }
.select-option.active { background: #e3f2fd; color: #0066cc; font-weight: 500; }
@media (max-width: 768px) {
    .custom-select-wrapper { min-width: 140px; }
    .select-display { min-width: 140px; font-size: 15px !important; }
    .select-options { min-width: 140px; }
    .select-option { font-size: 15px !important; padding: 10px 12px !important; min-width: 120px; }
}
@media (max-width: 480px) {
    .custom-select-wrapper { min-width: 130px; }
    .select-display { min-width: 130px; padding: 10px 12px; }
    .select-options { min-width: 130px; }
    .select-option { padding: 8px 10px !important; font-size: 14px !important; min-width: 110px; }
}
.region-select { display: none; }

/* ----- Input Validation ----- */
.tenant-input.invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220,53,69,0.1);
}
.input-validation-warning {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px; margin-top: 8px;
    border-radius: 6px; font-size: 14px; animation: slideDown 0.3s ease-out;
}
.input-validation-warning.domain-warning {
    background: #fff3cd; border: 1px solid #ffeaa7; color: #856404;
}
.input-validation-warning.character-warning {
    background: #f8d7da; border: 1px solid #f5c6cb; color: #721c24;
}
.input-validation-warning.length-warning {
    background: #d1ecf1; border: 1px solid #bee5eb; color: #0c5460;
}
.warning-icon { font-size: 16px; flex-shrink: 0; }
.warning-text { flex: 1; font-weight: 500; }
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px);}
    to { opacity: 1; transform: translateY(0);}
}

/* ----- Check Button and Spinner ----- */
.check-button {
    background: #0066cc; color: #fff; border: none;
    padding: 12px 24px; border-radius: 8px; font-size: 16px; font-weight: 600;
    cursor: pointer; transition: all 0.3s; position: relative;
    min-width: 140px; height: 48px; box-sizing: border-box;
}
.check-button:hover {
    background: #0052a3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,102,204,0.3);
}
.check-button:disabled { background: #6c757d; cursor: not-allowed; transform: none; }
.loading-spinner {
    display: none; width: 16px; height: 16px;
    border: 2px solid #ffffff40; border-top: 2px solid #fff;
    border-radius: 50%; animation: spin 1s linear infinite; margin-left: 8px;
}
.check-button.loading .button-text { opacity: 0.7; }
.check-button.loading .loading-spinner { display: inline-block; }
@keyframes spin { 0%{transform: rotate(0);} 100%{transform: rotate(360deg);} }

/* ----- Results Section ----- */
.m365-results-section {
    background: #fff; border: 1px solid #e9ecef; border-radius: 12px;
    padding: 30px; margin-bottom: 30px; box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.results-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 25px; padding-bottom: 15px; border-bottom: 1px solid #e9ecef;
}
.results-header h3 { margin: 0; color: #2c3e50; font-size: 20px; }
.results-meta { display: flex; gap: 15px; font-size: 14px; color: #6c757d; }
.main-result {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px; background: #f8f9fa; border-radius: 8px; margin-bottom: 25px;
}
.result-status { display: flex; align-items: center; gap: 15px; }
.status-icon {
    width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.status-icon.available { background: #d4edda; color: #155724; }
.status-icon.available::before { content: "✓"; }
.status-icon.taken { background: #f8d7da; color: #721c24; }
.status-icon.taken::before { content: "✗"; }
.status-content { flex: 1; }
.status-title { font-size: 18px; font-weight: 600; margin-bottom: 5px; }
.status-title.available { color: #155724; }
.status-title.taken { color: #721c24; }
.status-description { color: #6c757d; font-size: 14px; }
.result-actions {
    display: flex; justify-content: center; padding-top: 20px; border-top: 1px solid #e9ecef;
}
.action-button {
    padding: 10px 20px; border-radius: 6px; font-size: 14px; font-weight: 500;
    cursor: pointer; transition: all 0.3s; border: none;
}
.action-button.primary { background: #0066cc; color: #fff; }
.action-button.primary:hover { background: #0052a3; }
.action-button.copied { background: #28a745 !important; transform: scale(1.05); }

/* ----- Error Section ----- */
.m365-error-section {
    background: #f8d7da; border: 1px solid #f5c6cb; border-radius: 8px;
    padding: 20px; margin-bottom: 30px; text-align: center;
}
.error-content { display: flex; flex-direction: column; align-items: center; gap: 15px; }
.error-icon { font-size: 24px; }
.error-message { color: #721c24; font-weight: 500; }
.retry-button {
    background: #dc3545; color: #fff; border: none; padding: 8px 16px; border-radius: 6px;
    cursor: pointer; font-size: 14px;
}
.retry-button:hover { background: #c82333; }

/* ----- Recent Searches ----- */
.m365-recent-section {
    background: #fff; border: 1px solid #e9ecef; border-radius: 12px;
    padding: 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); display: none;
}
.m365-recent-section h4 { color: #2c3e50; font-size: 16px; margin-bottom: 15px; }
.recent-searches { display: flex; flex-direction: column; gap: 10px; }
.recent-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 15px; background: #f8f9fa; border-radius: 6px;
    transition: background 0.2s; position: relative;
}
.recent-item:hover { background: #e9ecef; }
.recent-content { display: flex; align-items: center; gap: 15px; flex: 1; cursor: pointer; }
.recent-tenant { font-weight: 500; color: #0066cc; cursor: pointer; text-decoration: none; }
.recent-tenant:hover { text-decoration: underline; }
.recent-status { padding: 2px 6px; border-radius: 8px; font-size: 10px; font-weight: 500; text-transform: uppercase; }
.recent-actions { display: flex; align-items: center; gap: 10px; z-index: 2; position: relative; }
.recent-time { font-size: 12px; color: #6c757d; }
.no-recent { color: #6c757d; font-style: italic; text-align: center; margin: 0; padding: 20px; }

/* ----- Copy Button: Unified, Responsive, Accessible ----- */
.copy-recent-btn,
.copy-current-result {
    background: #0066cc;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    cursor: pointer;
}
.copy-recent-btn {
    width: 28px;
    height: 28px;
    opacity: 0.7;
}
.copy-recent-btn:before {
    content: "📋";
    font-style: normal;
    font-family: system-ui, -apple-system, sans-serif;
}
.copy-recent-btn.disabled,
.copy-recent-btn:disabled {
    background: #6c757d !important;
    cursor: not-allowed !important;
    opacity: 0.4 !important;
    transform: none !important;
}
.copy-recent-btn.disabled:before,
.copy-recent-btn:disabled:before {
    content: "🚫";
}
.copy-recent-btn:not(.disabled):not(:disabled).copied {
    background: #28a745 !important;
    transform: scale(1.05);
}
.copy-recent-btn:not(.disabled):not(:disabled).copied:before {
    content: "✓";
    font-weight: bold;
}
.copy-recent-btn:not(.disabled):not(:disabled).copy-error {
    background: #dc3545 !important;
    animation: shake 0.5s ease-in-out;
}
.copy-recent-btn:not(.disabled):not(:disabled).copy-error:before {
    content: "✗";
}
.recent-item:hover .copy-recent-btn:not(.disabled):not(:disabled) { opacity: 1; }
.copy-recent-btn:not(.disabled):not(:disabled):hover:not(.copied):not(.copy-error) {
    background: #0052a3;
    transform: scale(1.1);
}
/* Copy button: mobile larger */
@media (max-width: 768px) {
    .copy-recent-btn { width: 32px; height: 32px; font-size: 14px; }
    .recent-actions { gap: 8px; }
}
.copy-current-result {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    gap: 8px;
}
.copy-current-result:hover:not(.copied):not(.copy-error) {
    background: #0052a3;
    transform: translateY(-1px);
}
.copy-current-result.copied {
    background: #28a745 !important;
    transform: scale(1.05);
}
.copy-current-result.copy-error {
    background: #dc3545 !important;
    animation: shake 0.5s ease-in-out;
}
@keyframes shake {
    0%,100%{transform:translateX(0);}
    25%{transform:translateX(-5px);}
    75%{transform:translateX(5px);}
}

/* ----- Toast Notification Styles ----- */
.m365-toast {
    position: fixed; top: 20px; right: 20px;
    padding: 12px 16px; border-radius: 4px; z-index: 10000;
    font-size: 14px; font-weight: 500; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease-out;
}
.toast-success { background: #4caf50; color: #fff; }
.toast-error { background: #f44336; color: #fff; }
.toast-info { background: #2196f3; color: #fff; }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ----- Accessibility & Focus ----- */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.copy-recent-btn:focus,
.copy-current-result:focus {
    outline: 2px solid #0078d4;
    outline-offset: 2px;
}

/* ----- Mobile Responsive Design ----- */
@media (max-width: 768px) {
    .m365-tenant-checker-page { padding: 15px; }
    .m365-search-form .form-row { flex-direction: column; align-items: stretch; }
    .input-group, .region-group { min-width: auto; }
    .select-display { font-size: 15px !important; }
    .select-option { font-size: 15px !important; padding: 10px 15px !important; }
    .tenant-input { padding-right: 120px !important; font-size: 16px !important; }
    .input-suffix { font-size: 12px !important; right: 10px !important; max-width: 100px; }
    .kb-link { display: block; margin-left: 0; margin-top: 8px; text-align: center; padding: 8px 12px; background: rgba(0,102,204,0.05); border-radius: 6px; }
    .main-result { flex-direction: column; gap: 15px; text-align: center; }
    .result-actions { flex-direction: column; align-items: stretch; }
    .results-header { flex-direction: column; gap: 10px; text-align: center; }
    .results-meta { justify-content: center; font-size: 12px; }
    .m365-toast { right: 10px; left: 10px; top: 10px; text-align: center; }
}
@media (max-width: 576px) {
    .tenant-input { padding-right: 110px !important; font-size: 15px !important; }
    .input-suffix { font-size: 11px !important; right: 8px !important; max-width: 90px; }
}
@media (max-width: 480px) {
    .tenant-input { padding-right: 100px !important; font-size: 15px !important; }
    .input-suffix { right: 8px !important; font-size: 10px !important; max-width: 80px; }
}
@media (max-width: 400px) {
    .tenant-input { padding-right: 15px !important; }
    .input-suffix { display: none; }
}

/* ----- High Contrast and Reduced Motion ----- */
@media (prefers-contrast: high) {
    .copy-recent-btn, .copy-current-result { border: 2px solid #fff; }
}
@media (prefers-reduced-motion: reduce) {
    .copy-recent-btn, .copy-current-result, .m365-toast { transition: none; animation: none; }
    .copy-recent-btn.copied, .copy-current-result.copied { transform: none; }
}
