/* ============================================
   Accounting AI Solver — WordPress Plugin Styles
   Matching the Lovable App Design
   ============================================ */

:root {
    --aas-bg: hsl(210, 50%, 98%);
    --aas-foreground: hsl(215, 25%, 17%);
    --aas-card: hsl(0, 0%, 100%);
    --aas-card-foreground: hsl(215, 25%, 17%);
    --aas-primary: hsl(210, 80%, 52%);
    --aas-primary-foreground: hsl(0, 0%, 100%);
    --aas-secondary: hsl(210, 40%, 94%);
    --aas-secondary-foreground: hsl(215, 25%, 27%);
    --aas-muted: hsl(210, 30%, 95%);
    --aas-muted-foreground: hsl(215, 15%, 50%);
    --aas-accent: hsl(200, 75%, 95%);
    --aas-accent-foreground: hsl(210, 80%, 40%);
    --aas-border: hsl(210, 25%, 90%);
    --aas-destructive: hsl(0, 84%, 60%);
    --aas-ring: hsl(210, 80%, 52%);
    --aas-radius: 0.75rem;
    --aas-hero-gradient: linear-gradient(135deg, hsl(210, 80%, 52%) 0%, hsl(200, 85%, 60%) 50%, hsl(190, 90%, 65%) 100%);
    --aas-card-shadow: 0 4px 24px -4px hsla(210, 80%, 52%, 0.08);
    --aas-card-shadow-hover: 0 8px 32px -4px hsla(210, 80%, 52%, 0.15);
}

/* Reset & Base */
.aas-wrapper {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--aas-foreground);
    background: var(--aas-bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.aas-wrapper *,
.aas-wrapper *::before,
.aas-wrapper *::after {
    box-sizing: border-box;
}

/* Header / Navbar */
.aas-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: hsla(0, 0%, 100%, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--aas-border);
}

.aas-header-inner {
    max-width: 72rem;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.aas-logo-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--aas-hero-gradient);
    flex-shrink: 0;
}

.aas-logo-icon svg {
    width: 20px;
    height: 20px;
    color: var(--aas-primary-foreground);
    stroke: currentColor;
    fill: none;
}

.aas-logo-text {
    flex: 1;
    min-width: 0;
}

.aas-logo-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--aas-foreground);
    margin: 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aas-logo-text p {
    font-size: 0.75rem;
    color: var(--aas-muted-foreground);
    margin: 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Main Layout */
.aas-main {
    max-width: 72rem;
    margin: 0 auto;
    padding: 16px;
}

.aas-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 1024px) {
    .aas-layout {
        grid-template-columns: 1fr 300px;
        gap: 32px;
    }
    .aas-main {
        padding: 32px 16px;
    }
}

.aas-content {
    min-width: 0;
}

/* Hero Banner */
.aas-hero {
    border-radius: 16px;
    padding: 32px;
    color: var(--aas-primary-foreground);
    background: var(--aas-hero-gradient);
    margin-bottom: 24px;
}

.aas-hero h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 8px;
    line-height: 1.3;
}

.aas-hero p {
    font-size: 0.875rem;
    opacity: 0.9;
    margin: 0;
    line-height: 1.5;
}

/* Card */
.aas-card {
    background: var(--aas-card);
    border-radius: var(--aas-radius);
    border: 1px solid var(--aas-border);
    box-shadow: var(--aas-card-shadow);
    padding: 20px;
    margin-bottom: 24px;
}

/* Tabs */
.aas-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--aas-secondary);
    border-radius: 10px;
    padding: 4px;
}

.aas-tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--aas-muted-foreground);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    text-align: center;
}

.aas-tab-btn.active {
    color: var(--aas-card-foreground);
    background: var(--aas-card);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.aas-tab-btn:hover:not(.active) {
    color: var(--aas-foreground);
}

/* Tab Content */
.aas-tab-content {
    display: none;
}

.aas-tab-content.active {
    display: block;
}

/* Textarea */
.aas-textarea {
    width: 100%;
    min-height: 120px;
    border: none;
    background: transparent;
    outline: none;
    resize: none;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--aas-card-foreground);
    line-height: 1.7;
    padding: 0;
}

.aas-textarea::placeholder {
    color: var(--aas-muted-foreground);
}

/* Input Bottom Bar */
.aas-input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--aas-border);
}

.aas-input-actions .aas-spacer {
    flex: 1;
}

/* Buttons */
.aas-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    line-height: 1.4;
}

.aas-btn-secondary {
    background: var(--aas-secondary);
    color: var(--aas-secondary-foreground);
}

.aas-btn-secondary:hover {
    background: hsl(210, 40%, 90%);
}

.aas-btn-primary {
    background: var(--aas-hero-gradient);
    color: var(--aas-primary-foreground);
    font-weight: 600;
    padding: 10px 24px;
}

.aas-btn-primary:hover {
    opacity: 0.9;
}

.aas-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.aas-btn-ghost {
    background: transparent;
    color: var(--aas-muted-foreground);
    padding: 8px;
    border-radius: 10px;
}

.aas-btn-ghost:hover {
    background: var(--aas-secondary);
}

/* Full-width submit for image tab */
.aas-submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: var(--aas-hero-gradient);
    color: var(--aas-primary-foreground);
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    margin-top: 16px;
}

.aas-submit-btn:hover {
    opacity: 0.9;
}

.aas-submit-btn:active {
    transform: scale(0.98);
}

.aas-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Spinner */
.aas-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: aas-spin 0.7s linear infinite;
}

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

/* Image Upload */
.aas-upload-area {
    border: 2px dashed var(--aas-border);
    border-radius: var(--aas-radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--aas-muted);
}

.aas-upload-area:hover,
.aas-upload-area.dragover {
    border-color: var(--aas-primary);
    background: var(--aas-accent);
}

.aas-upload-area svg {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    color: var(--aas-muted-foreground);
    display: block;
}

.aas-upload-area p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--aas-muted-foreground);
}

.aas-upload-area .aas-upload-label {
    font-weight: 600;
    color: var(--aas-primary);
    cursor: pointer;
}

.aas-upload-input {
    display: none;
}

/* Image Preview */
.aas-image-preview {
    display: none;
    position: relative;
    margin-top: 12px;
    text-align: center;
}

.aas-image-preview img {
    max-height: 200px;
    border-radius: 12px;
    border: 1px solid var(--aas-border);
}

.aas-image-preview .aas-remove-img {
    position: absolute;
    top: -8px;
    right: calc(50% - 108px);
    width: 24px;
    height: 24px;
    background: var(--aas-destructive);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Sidebar */
.aas-sidebar {
    display: none;
}

@media (min-width: 1024px) {
    .aas-sidebar {
        display: block;
    }
}

.aas-sidebar-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--aas-muted-foreground);
    margin: 0 0 12px;
}

/* Example Buttons — sidebar style */
.aas-examples-list {
    display: grid;
    gap: 8px;
}

.aas-example-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--aas-border);
    border-radius: var(--aas-radius);
    background: var(--aas-card);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--aas-card-foreground);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
}

.aas-example-btn:hover {
    border-color: hsla(210, 80%, 52%, 0.3);
    box-shadow: var(--aas-card-shadow-hover);
}

.aas-example-btn .aas-example-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--aas-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.2s;
}

.aas-example-btn:hover .aas-example-icon {
    background: hsla(210, 80%, 52%, 0.1);
}

/* Mobile Examples — pills row */
.aas-examples-mobile {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

@media (min-width: 1024px) {
    .aas-examples-mobile {
        display: none;
    }
}

.aas-example-pill {
    padding: 8px 14px;
    border: 1px solid var(--aas-border);
    border-radius: 20px;
    background: var(--aas-card);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--aas-card-foreground);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.aas-example-pill:hover {
    border-color: var(--aas-primary);
    color: var(--aas-primary);
    background: var(--aas-accent);
}

/* Solution Display */
.aas-solution-wrapper {
    display: none;
    margin-bottom: 24px;
}

.aas-solution-wrapper.visible {
    display: block;
    animation: aas-fadeIn 0.4s ease;
}

@keyframes aas-fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.aas-solution-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
    color: var(--aas-card-foreground);
}

.aas-solution-header-actions {
    display: flex;
    gap: 4px;
}

.aas-solution-content {
    line-height: 1.75;
    font-size: 0.875rem;
    overflow-x: auto;
}

/* Solution rendered elements */
.aas-solution-content h2 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--aas-primary);
    margin: 24px 0 8px;
}

.aas-solution-content h2:first-child {
    margin-top: 0;
}

.aas-solution-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 16px 0 8px;
}

.aas-solution-content p {
    color: hsla(215, 25%, 17%, 0.85);
    margin: 4px 0;
    line-height: 1.75;
}

.aas-solution-content strong {
    font-weight: 700;
    color: var(--aas-card-foreground);
}

.aas-solution-content code {
    background: var(--aas-muted);
    color: var(--aas-accent-foreground);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8125rem;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

.aas-solution-content pre {
    background: hsl(215, 25%, 17%);
    color: hsl(210, 25%, 90%);
    padding: 16px;
    border-radius: var(--aas-radius);
    overflow-x: auto;
    font-size: 0.8125rem;
}

.aas-solution-content ul,
.aas-solution-content ol {
    padding-left: 20px;
    margin: 8px 0;
}

.aas-solution-content li {
    color: hsla(215, 25%, 17%, 0.85);
    line-height: 1.75;
    margin-left: 16px;
    list-style: disc;
}

/* Highlighted label lines (Req, Working, etc.) */
.aas-highlight-block {
    margin-top: 16px;
    margin-bottom: 4px;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--aas-accent);
    border-left: 4px solid var(--aas-primary);
}

.aas-highlight-block p {
    color: var(--aas-card-foreground);
    font-weight: 500;
    margin: 0;
}

/* Tables */
.aas-solution-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    border-radius: var(--aas-radius);
    overflow: hidden;
    border: 1px solid var(--aas-border);
}

.aas-solution-content th {
    background: var(--aas-secondary);
    font-weight: 600;
    color: var(--aas-secondary-foreground);
    padding: 10px 16px;
    text-align: left;
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--aas-border);
    white-space: nowrap;
}

.aas-solution-content td {
    padding: 8px 16px;
    text-align: left;
    font-size: 0.8125rem;
    color: var(--aas-card-foreground);
    border-bottom: 1px solid hsla(210, 25%, 90%, 0.5);
    white-space: nowrap;
}

.aas-solution-content tr:nth-child(even) {
    background: hsla(210, 30%, 95%, 0.3);
}

/* Section Badges */
.aas-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 8px;
}

.aas-badge-topic {
    background: hsl(210, 100%, 93%);
    color: hsl(210, 80%, 35%);
}

.aas-badge-formula {
    background: hsl(45, 100%, 91%);
    color: hsl(30, 80%, 30%);
}

.aas-badge-steps {
    background: hsl(150, 60%, 92%);
    color: hsl(160, 60%, 25%);
}

.aas-badge-answer {
    background: hsl(270, 60%, 95%);
    color: hsl(270, 60%, 35%);
}

/* Action Buttons row */
.aas-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--aas-border);
}

.aas-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid var(--aas-border);
    border-radius: 10px;
    background: var(--aas-card);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--aas-foreground);
    cursor: pointer;
    transition: all 0.2s;
}

.aas-action-btn:hover {
    border-color: var(--aas-primary);
    color: var(--aas-primary);
}

.aas-action-btn.primary {
    background: var(--aas-primary);
    color: var(--aas-primary-foreground);
    border-color: var(--aas-primary);
}

.aas-action-btn.primary:hover {
    opacity: 0.9;
}

/* Error */
.aas-error {
    background: hsl(0, 100%, 97%);
    border: 1px solid hsl(0, 70%, 85%);
    color: var(--aas-destructive);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 0.875rem;
    margin-top: 16px;
    display: none;
}

.aas-error.visible {
    display: block;
    animation: aas-fadeIn 0.3s ease;
}

/* History items */
.aas-history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--aas-border);
    border-radius: var(--aas-radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--aas-card);
}

.aas-history-item:hover {
    border-color: hsla(210, 80%, 52%, 0.3);
    box-shadow: var(--aas-card-shadow-hover);
}

.aas-history-item .aas-hist-text {
    flex: 1;
    min-width: 0;
}

.aas-history-item .aas-hist-text p {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aas-history-item .aas-hist-text span {
    font-size: 0.6875rem;
    color: var(--aas-muted-foreground);
}

/* Responsive */
@media (min-width: 640px) {
    .aas-header-inner {
        padding: 12px 24px;
    }
    .aas-hero {
        padding: 40px 32px;
    }
    .aas-hero h2 {
        font-size: 1.75rem;
    }
}

@media (max-width: 480px) {
    .aas-hero {
        border-radius: 12px;
        padding: 24px 16px;
    }
    .aas-hero h2 {
        font-size: 1.25rem;
    }
    .aas-card {
        padding: 16px;
    }
    .aas-actions {
        flex-direction: column;
    }
    .aas-action-btn {
        justify-content: center;
    }
}
