/**
 * All-in-One Tools Hub - Frontend Base Styles
 * Minimal reset, layout, typography, form elements, and utilities.
 * Heavy design lives in premium-ui.css — keep this lean.
 */

/* ============================================
   1. PLUGIN ELEMENT RESET
   ============================================ */
.aiot-container *,
.aiot-container *::before,
.aiot-container *::after,
.aiot-tool-wrapper *,
.aiot-tool-wrapper *::before,
.aiot-tool-wrapper *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ============================================
   2. TYPOGRAPHY DEFAULTS
   ============================================ */
.aiot-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--aiot-text-primary, #1e293b);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.aiot-container h1, .aiot-container h2, .aiot-container h3,
.aiot-container h4, .aiot-container h5, .aiot-container h6 {
    line-height: 1.25;
    color: var(--aiot-text-primary, #1e293b);
    font-weight: 700;
}

.aiot-container h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
.aiot-container h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
.aiot-container h3 { font-size: 1.25rem; }
.aiot-container h4 { font-size: 1.125rem; }

.aiot-container a {
    color: var(--aiot-primary, #6366f1);
    text-decoration: none;
    transition: color 0.2s ease;
}

.aiot-container a:hover {
    color: var(--aiot-primary-dark, #4f46e5);
    text-decoration: underline;
}

.aiot-container img {
    max-width: 100%;
    height: auto;
    display: block;
}

.aiot-container ul, .aiot-container ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.aiot-container li { margin-bottom: 0.25rem; }

/* ============================================
   3. LAYOUT & CONTAINERS
   ============================================ */
.aiot-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.aiot-container-wide {
    max-width: 1400px;
}

.aiot-container-narrow {
    max-width: 800px;
}

.aiot-flex-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.aiot-flex-col {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.aiot-main-content {
    flex: 1;
    min-width: 0;
}

.aiot-sidebar-area {
    width: 320px;
    flex-shrink: 0;
}

/* ============================================
   4. BASIC FORM ELEMENTS
   ============================================ */
.aiot-container input[type="text"],
.aiot-container input[type="email"],
.aiot-container input[type="url"],
.aiot-container input[type="number"],
.aiot-container input[type="password"],
.aiot-container input[type="search"],
.aiot-container input[type="tel"],
.aiot-container textarea,
.aiot-container select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.5;
    color: #1e293b;
    background-color: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    appearance: none;
}

.aiot-container input:focus,
.aiot-container textarea:focus,
.aiot-container select:focus {
    outline: none;
    border-color: var(--aiot-primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.aiot-container input::placeholder,
.aiot-container textarea::placeholder {
    color: #94a3b8;
}

.aiot-container textarea {
    min-height: 120px;
    resize: vertical;
}

.aiot-container select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 6.646a.5.5 0 0 1 .708 0L8 9.293l2.646-2.647a.5.5 0 0 1 .708.708l-3 3a.5.5 0 0 1-.708 0l-3-3a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

/* Buttons */
.aiot-container button,
.aiot-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.5;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

.aiot-btn:hover { text-decoration: none; }

.aiot-btn-primary {
    background: var(--aiot-primary, #6366f1);
    color: #fff;
}

.aiot-btn-primary:hover {
    background: var(--aiot-primary-dark, #4f46e5);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.aiot-btn-secondary {
    background: #f1f5f9;
    color: #334155;
    border-color: #e2e8f0;
}

.aiot-btn-secondary:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.aiot-btn-danger {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}

.aiot-btn-danger:hover {
    background: #dc2626;
    color: #fff;
}

.aiot-btn-success {
    background: #dcfce7;
    color: #16a34a;
    border-color: #bbf7d0;
}

.aiot-btn-success:hover {
    background: #16a34a;
    color: #fff;
}

.aiot-btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.aiot-btn-lg { padding: 0.875rem 1.75rem; font-size: 1.0625rem; }
.aiot-btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ============================================
   5. UTILITY CLASSES
   ============================================ */

/* Text alignment */
.aiot-text-left   { text-align: left; }
.aiot-text-center { text-align: center; }
.aiot-text-right  { text-align: right; }

/* Spacing - margin bottom */
.aiot-mb-0  { margin-bottom: 0 !important; }
.aiot-mb-1  { margin-bottom: 0.5rem !important; }
.aiot-mb-2  { margin-bottom: 1rem !important; }
.aiot-mb-3  { margin-bottom: 1.5rem !important; }
.aiot-mb-4  { margin-bottom: 2rem !important; }
.aiot-mb-5  { margin-bottom: 3rem !important; }

/* Spacing - margin top */
.aiot-mt-0  { margin-top: 0 !important; }
.aiot-mt-1  { margin-top: 0.5rem !important; }
.aiot-mt-2  { margin-top: 1rem !important; }
.aiot-mt-3  { margin-top: 1.5rem !important; }
.aiot-mt-4  { margin-top: 2rem !important; }

/* Spacing - padding */
.aiot-p-0  { padding: 0 !important; }
.aiot-p-2  { padding: 1rem !important; }
.aiot-p-3  { padding: 1.5rem !important; }
.aiot-p-4  { padding: 2rem !important; }

/* Flex helpers */
.aiot-flex          { display: flex; }
.aiot-flex-wrap     { flex-wrap: wrap; }
.aiot-flex-center   { display: flex; align-items: center; justify-content: center; }
.aiot-flex-between  { display: flex; align-items: center; justify-content: space-between; }
.aiot-flex-start    { display: flex; align-items: center; justify-content: flex-start; }
.aiot-flex-1        { flex: 1; min-width: 0; }
.aiot-gap-1 { gap: 0.5rem; }
.aiot-gap-2 { gap: 1rem; }
.aiot-gap-3 { gap: 1.5rem; }

/* Display */
.aiot-hidden  { display: none !important; }
.aiot-block   { display: block !important; }
.aiot-inline  { display: inline-block !important; }

/* Text utilities */
.aiot-text-sm   { font-size: 0.8125rem; }
.aiot-text-xs   { font-size: 0.75rem; }
.aiot-text-lg   { font-size: 1.125rem; }
.aiot-text-muted { color: #64748b; }
.aiot-text-bold { font-weight: 700; }
.aiot-truncate  { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Borders */
.aiot-rounded    { border-radius: 8px; }
.aiot-rounded-lg { border-radius: 16px; }
.aiot-rounded-full { border-radius: 9999px; }

/* ============================================
   6. SECTION SPACING
   ============================================ */
.aiot-section {
    padding: 3rem 0;
}

.aiot-section-sm {
    padding: 1.5rem 0;
}

.aiot-section-lg {
    padding: 4rem 0;
}

/* ============================================
   7. CARD BASE
   ============================================ */
.aiot-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.aiot-card:hover {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

/* ============================================
   8. LOADING & ANIMATIONS
   ============================================ */
.aiot-loading { position: relative; pointer-events: none; }

.aiot-loading::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 20px; height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #e2e8f0;
    border-top-color: var(--aiot-primary, #6366f1);
    border-radius: 50%;
    animation: aiot-spin 0.7s linear infinite;
}

@keyframes aiot-spin { to { transform: rotate(360deg); } }

@keyframes aiot-fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes aiot-slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.aiot-animate-fade-in  { animation: aiot-fadeIn 0.4s ease; }
.aiot-animate-slide-up { animation: aiot-slideUp 0.4s ease; }

/* ============================================
   9. ACCESSIBILITY
   ============================================ */
.aiot-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;
}

.aiot-container *:focus-visible {
    outline: 2px solid var(--aiot-primary, #6366f1);
    outline-offset: 2px;
}

/* ============================================
   10. RESPONSIVE RESETS
   ============================================ */
@media (max-width: 1024px) {
    .aiot-flex-row { gap: 1rem; }
    .aiot-sidebar-area { width: 280px; }
}

@media (max-width: 768px) {
    .aiot-container { padding: 0 0.75rem; }
    .aiot-section { padding: 2rem 0; }
    .aiot-section-lg { padding: 2.5rem 0; }

    .aiot-flex-row { flex-direction: column; }
    .aiot-sidebar-area { width: 100%; }

    .aiot-container input,
    .aiot-container textarea,
    .aiot-container select {
        font-size: 16px; /* prevent iOS zoom */
    }
}

@media (max-width: 480px) {
    .aiot-section { padding: 1.5rem 0; }
    .aiot-card { padding: 1rem; }
    .aiot-btn { padding: 0.5rem 1rem; font-size: 0.875rem; }
}

/* ============================================
   11. CONSENT MANAGER
   ============================================ */
.aiot-consent-banner {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    z-index: 99999;
}

.aiot-consent-card {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    justify-content: space-between;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.25rem;
    background: #0f172a;
    color: #f8fafc;
    border-radius: 16px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.25);
}

.aiot-consent-copy {
    flex: 1 1 420px;
}

.aiot-consent-copy h3 {
    margin-bottom: 0.5rem;
    color: #ffffff;
    font-size: 1.125rem;
}

.aiot-consent-copy p {
    margin: 0;
    color: rgba(248, 250, 252, 0.9);
}

.aiot-consent-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.75rem !important;
}

.aiot-consent-links a {
    color: #93c5fd;
    font-weight: 600;
}

.aiot-consent-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
}

.aiot-consent-modal[hidden],
.aiot-consent-banner[hidden] {
    display: none !important;
}

.aiot-consent-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
}

.aiot-consent-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}

.aiot-consent-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(680px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow: auto;
    margin: 1rem auto;
    padding: 1.5rem;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
}

.aiot-consent-modal__close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: #f1f5f9;
    color: #0f172a;
    cursor: pointer;
}

.aiot-consent-modal__intro {
    margin: 0.75rem 0 1rem;
    color: #475569;
}

.aiot-consent-options {
    display: grid;
    gap: 0.75rem;
}

.aiot-consent-option {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
}

.aiot-consent-option span {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.aiot-consent-option small {
    color: #64748b;
}

.aiot-consent-option input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

.aiot-consent-modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

.aiot-consent-placeholder {
    margin: 1rem 0;
    padding: 1rem;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    background: #f8fafc;
}

.aiot-consent-placeholder strong {
    display: block;
    margin-bottom: 0.4rem;
}

.aiot-consent-placeholder p {
    margin-bottom: 0.75rem;
    color: #475569;
}

body.aiot-consent-modal-open {
    overflow: hidden;
}

/* ============================================
   12. PRINT
   ============================================ */
@media print {
    .aiot-container * { box-shadow: none !important; }
    .aiot-container a { color: inherit !important; text-decoration: none !important; }
    .aiot-btn { display: none !important; }
}

/* ============================================
   13. REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .aiot-container *,
    .aiot-container *::before,
    .aiot-container *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 768px) {
    .aiot-consent-card {
        padding: 1rem;
    }

    .aiot-consent-actions,
    .aiot-consent-modal__actions {
        width: 100%;
        justify-content: stretch;
    }

    .aiot-consent-actions .aiot-btn,
    .aiot-consent-modal__actions .aiot-btn {
        width: 100%;
    }

    .aiot-consent-option {
        align-items: flex-start;
    }
}
