/* ============================================
   MANDAT AEO ASSISTANT - PROFESSIONAL UI/UX
   Modern Design System with Enhanced User Experience
   ============================================ */

/* === CSS VARIABLES === */
:root {
    --maao-primary: #2563eb;
    --maao-primary-hover: #1d4ed8;
    --maao-primary-light: #dbeafe;
    --maao-success: #10b981;
    --maao-warning: #f59e0b;
    --maao-error: #ef4444;
    --maao-text-primary: #111827;
    --maao-text-secondary: #6b7280;
    --maao-text-muted: #9ca3af;
    --maao-border: #e5e7eb;
    --maao-border-hover: #d1d5db;
    --maao-bg-card: #ffffff;
    --maao-bg-hover: #f9fafb;
    --maao-bg-active: #f3f4f6;
    --maao-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --maao-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --maao-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --maao-radius-sm: 6px;
    --maao-radius-md: 8px;
    --maao-radius-lg: 12px;
    --maao-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === GENERAL LAYOUT === */
.wrap.maao-wrap {
    margin: 20px 40px 40px 20px;
}

.wrap.maao-wrap > h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--maao-text-primary);
    margin: 0 0 24px 0;
    padding: 0;
    letter-spacing: -0.02em;
}

.maao-grid {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 20px;
    margin-top: 20px;
    position: relative;
}

@media screen and (min-width: 1600px) {
    .maao-grid {
        grid-template-columns: 380px 1fr;
        gap: 28px;
    }
}

/* === MODERN CARD DESIGN === */
.maao-card {
    position: relative;
    background: var(--maao-bg-card);
    border: 1px solid var(--maao-border);
    border-radius: var(--maao-radius-lg);
    padding: 0;
    box-shadow: var(--maao-shadow-sm);
    transition: var(--maao-transition);
    overflow: hidden;
}

.maao-card:hover {
    box-shadow: var(--maao-shadow-md);
}

/* Card Header */
.maao-card > h2:first-child {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin: 0;
    padding: 20px 24px;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
    border-radius: var(--maao-radius-lg) var(--maao-radius-lg) 0 0;
}

.maao-card > *:last-child {
    padding-bottom: 24px;
}

/* === FORM ELEMENTS === */
.maao-card .form-table {
    margin: 24px 0 0 0;
    border-collapse: separate;
    border-spacing: 0;
    padding: 12px 12px 12px 12px;
}

.maao-card .form-table th {
    padding: 12px 12px 12px 0;
    font-weight: 600;
    color: var(--maao-text-primary);
    font-size: 13px;
    vertical-align: top;
    padding-top: 16px;
}

.maao-card .form-table td {
    padding: 12px 0;
}

.maao-card .form-table tr {
    border-bottom: 1px solid var(--maao-border);
}

.maao-card .form-table tr:last-child {
    border-bottom: none;
}

/* Input Styles */
.maao-card input[type="text"],
.maao-card input[type="number"],
.maao-card input[type="date"],
.maao-card input[type="time"],
.maao-card select,
.maao-card textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--maao-border);
    border-radius: var(--maao-radius-sm);
    font-size: 14px;
    color: var(--maao-text-primary);
    background: white;
    transition: var(--maao-transition);
    box-shadow: var(--maao-shadow-sm);
}

.maao-card input[type="text"]:focus,
.maao-card input[type="number"]:focus,
.maao-card input[type="date"]:focus,
.maao-card input[type="time"]:focus,
.maao-card select:focus,
.maao-card textarea:focus {
    outline: none;
    border-color: var(--maao-primary);
    box-shadow: 0 0 0 3px var(--maao-primary-light);
}

.maao-card input[type="text"]::placeholder {
    color: var(--maao-text-muted);
}

/* Checkbox & Radio Styles */
.maao-card input[type="checkbox"],
.maao-card input[type="radio"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    cursor: pointer;
    accent-color: var(--maao-primary);
}

.maao-card label {
    cursor: pointer;
    color: var(--maao-text-secondary);
    font-size: 14px;
    display: inline-flex;
    align-items: center;
}

/* Description Text */
.maao-card .description {
    font-size: 13px;
    color: var(--maao-text-muted);
    margin-top: 6px;
    line-height: 1.5;
}

.maao-card .required {
    color: var(--maao-error);
}

/* === MODERN BUTTONS === */
.button,
.button-primary,
.button-secondary,
.button-large {
    padding: 10px 20px;
    border-radius: var(--maao-radius-sm);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--maao-transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    box-shadow: var(--maao-shadow-sm);
}

/* Center submit buttons in forms */
.maao-card .submit,
.maao-card p.submit {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--maao-border);
}

.button-primary {
    background: linear-gradient(135deg, var(--maao-primary) 0%, var(--maao-primary-hover) 100%);
    color: white !important;
    border: none;
}

.button-primary:hover {
    background: linear-gradient(135deg, var(--maao-primary-hover) 0%, #1e40af 100%);
    transform: translateY(-1px);
    box-shadow: var(--maao-shadow-md);
}

.button-primary:active {
    transform: translateY(0);
}

.button-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.button-secondary {
    background: white;
    color: var(--maao-text-primary);
    border: 1.5px solid var(--maao-border);
}

.button-secondary:hover {
    background: var(--maao-bg-hover);
    border-color: var(--maao-border-hover);
}

.button-large {
    padding: 12px 24px;
    font-size: 15px;
}

/* === PLACEHOLDER === */
.maao-placeholder {
    text-align: center;
    padding: 80px 40px;
    color: var(--maao-text-secondary);
}

.maao-placeholder-icon {
    font-size: 64px;
    margin-bottom: 24px;
    opacity: 0.6;
    filter: grayscale(20%);
}

.maao-placeholder h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--maao-text-primary);
}

.maao-placeholder p {
    font-size: 15px;
    color: var(--maao-text-muted);
    line-height: 1.6;
}

/* === PREVIEW AREA === */
#maao-preview-title {
    font-size: 24px;
    font-weight: 700;
    margin: 24px 0 16px 0;
    color: var(--maao-text-primary);
    letter-spacing: -0.02em;
    padding: 0 24px;
}

#maao-preview-keywords {
    margin: 0 0 20px 0;
    padding: 0 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.maao-badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: var(--maao-shadow-sm);
    transition: var(--maao-transition);
}

.maao-badge:hover {
    transform: translateY(-2px);
    box-shadow: var(--maao-shadow-md);
}

/* === MODERN TABS === */
.maao-tabs {
    display: flex;
    gap: 4px;
    padding: 0 24px;
    border-bottom: 2px solid var(--maao-border);
    margin-bottom: 0;
    background: var(--maao-bg-hover);
}

.maao-tab-link {
    padding: 14px 20px;
    text-decoration: none;
    color: var(--maao-text-secondary);
    font-weight: 600;
    font-size: 14px;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: var(--maao-transition);
    cursor: pointer;
    border-radius: var(--maao-radius-sm) var(--maao-radius-sm) 0 0;
}

.maao-tab-link:hover {
    color: var(--maao-primary);
    background: white;
}

.maao-tab-link.active {
    color: var(--maao-primary);
    border-bottom-color: var(--maao-primary);
    background: white;
}

.maao-tab-link.disabled {
    color: var(--maao-text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

.maao-tab-link.disabled:hover {
    background: transparent;
    color: var(--maao-text-muted);
}

.maao-tab-panel {
    display: none;
    padding: 24px;
    animation: fadeIn 0.3s ease-in;
}

.maao-tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === EDITABLE CONTENT === */
.maao-editable-content {
    min-height: 500px;
    padding: 32px;
    border: 2px solid var(--maao-border);
    border-radius: var(--maao-radius-md);
    background: white;
    line-height: 1.8;
    font-size: 15px;
    color: var(--maao-text-primary);
    transition: var(--maao-transition);
}

.maao-editable-content:focus {
    outline: none;
    border-color: var(--maao-primary);
    box-shadow: 0 0 0 3px var(--maao-primary-light);
}

.maao-editable-content h1 {
    font-size: 36px !important;
    font-weight: 800 !important;
    line-height: 1.2 !important;
    margin-bottom: 1.2em !important;
    color: var(--maao-text-primary) !important;
    letter-spacing: -0.02em !important;
    text-align: left !important;
}

.maao-editable-content h2 {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.3;
    margin-top: 1.8em;
    margin-bottom: 0.8em;
    color: var(--maao-text-primary);
}

.maao-editable-content h3 {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.4;
    margin-top: 1.5em;
    margin-bottom: 0.6em;
    color: var(--maao-text-primary);
}

.maao-editable-content p {
    margin-bottom: 1.2em;
    line-height: 1.8;
}

.maao-editable-content ul,
.maao-editable-content ol {
    margin-left: 2em;
    margin-bottom: 1.5em;
}

.maao-editable-content li {
    margin-bottom: 0.8em;
    line-height: 1.7;
}

.maao-editable-content a {
    color: var(--maao-primary);
    text-decoration: underline;
    font-weight: 500;
}

.maao-editable-content img {
    max-width: 100%;
    height: auto;
    margin: 2em 0;
    border-radius: var(--maao-radius-md);
    box-shadow: var(--maao-shadow-lg);
}

/* === EDITOR TOOLBAR === */
.maao-editor-toolbar {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--maao-bg-hover);
    border: 1px solid var(--maao-border);
    border-radius: var(--maao-radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
}

/* === LOADING STATE === */
.maao-card.is-loading {
    position: relative;
}

.maao-card.is-loading::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 100;
    border-radius: var(--maao-radius-lg);
    backdrop-filter: blur(2px);
}

.maao-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border: 4px solid var(--maao-border);
    border-top-color: var(--maao-primary);
    border-radius: 50%;
    animation: maao-spin 0.8s linear infinite;
    z-index: 101;
}

@keyframes maao-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* === IMAGES TAB === */
#maao-image-results {
    margin-top: 24px;
}

#maao-image-results > div {
    margin-bottom: 32px;
}

#maao-image-results h4 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--maao-text-primary);
}

#maao-image-results img {
    max-width: 100%;
    height: auto;
    border: 2px solid var(--maao-border);
    border-radius: var(--maao-radius-md);
    box-shadow: var(--maao-shadow-md);
    transition: var(--maao-transition);
}

#maao-image-results img:hover {
    transform: scale(1.02);
    box-shadow: var(--maao-shadow-lg);
}

/* === CATEGORIES === */
.maao-category-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 16px;
    border: 2px solid var(--maao-border);
    border-radius: var(--maao-radius-md);
    background: var(--maao-bg-hover);
}

.maao-category-list label {
    display: block;
    padding: 10px 12px;
    cursor: pointer;
    transition: var(--maao-transition);
    border-radius: var(--maao-radius-sm);
    font-size: 14px;
}

.maao-category-list label:hover {
    background: white;
    box-shadow: var(--maao-shadow-sm);
}

/* === PUBLISH SECTION === */
.maao-publish-section {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 2px solid var(--maao-border);
}

.maao-publish-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--maao-text-primary);
}

#maao-schedule-options {
    display: none;
    margin-top: 16px;
    padding: 16px;
    background: var(--maao-bg-hover);
    border: 2px dashed var(--maao-border);
    border-radius: var(--maao-radius-md);
    gap: 12px;
}

#maao-schedule-options.visible {
    display: flex;
}

/* === NOTICES === */
.maao-help {
    text-align: center;
    padding: 60px 40px;
    color: var(--maao-text-muted);
    font-style: italic;
    font-size: 15px;
}

.notice {
    padding: 12px 16px;
    border-left: 4px solid;
    border-radius: var(--maao-radius-sm);
    margin: 20px 0;
}

.notice-success {
    background: #ecfdf5;
    border-color: var(--maao-success);
    color: #065f46;
}

.notice-error {
    background: #fef2f2;
    border-color: var(--maao-error);
    color: #991b1b;
}

.notice-info {
    background: #eff6ff;
    border-color: var(--maao-primary);
    color: #1e40af;
}

/* === STATUS INDICATORS === */
#maao-update-status,
#maao-category-status {
    font-size: 13px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 12px;
    display: inline-block;
}

/* === UI LOCKING === */
.maao-grid.maao-ui-locked::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 999;
    cursor: wait;
    backdrop-filter: blur(2px);
}

/* === RESPONSIVE === */
@media screen and (max-width: 1400px) {
    .maao-grid {
        grid-template-columns: 380px 1fr;
    }
}

@media screen and (max-width: 1024px) {
    .maao-grid {
        grid-template-columns: 1fr;
    }
    
    .wrap.maao-wrap {
        margin: 20px;
    }
}

/* === SCROLLBAR STYLING === */
.maao-category-list::-webkit-scrollbar,
.maao-editable-content::-webkit-scrollbar {
    width: 8px;
}

.maao-category-list::-webkit-scrollbar-track,
.maao-editable-content::-webkit-scrollbar-track {
    background: var(--maao-bg-hover);
    border-radius: 4px;
}

.maao-category-list::-webkit-scrollbar-thumb,
.maao-editable-content::-webkit-scrollbar-thumb {
    background: var(--maao-border-hover);
    border-radius: 4px;
}

.maao-category-list::-webkit-scrollbar-thumb:hover,
.maao-editable-content::-webkit-scrollbar-thumb:hover {
    background: var(--maao-text-muted);
}

/* === ACCESSIBILITY === */
.maao-tab-link:focus,
.maao-editable-content:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--maao-primary);
    outline-offset: 2px;
}

/* === PRINT STYLES === */
@media print {
    .maao-card {
        border: none;
        box-shadow: none;
        page-break-inside: avoid;
    }
    
    .maao-tabs,
    .maao-editor-toolbar,
    .button,
    .maao-publish-section {
        display: none !important;
    }
}

/* === TRANSLATION BADGE === */
.translation-badge {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    margin-top: 6px;
    box-shadow: var(--maao-shadow-sm);
}

/* === COST REPORT STYLES === */
.cost-breakdown ul {
    margin: 8px 0 16px 0;
    padding-left: 20px;
    list-style-type: disc;
}

.cost-breakdown li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.cost-breakdown small {
    color: var(--maao-text-muted);
}

.cost-breakdown strong {
    color: var(--maao-text-primary);
    font-weight: 600;
}

.total-cost-cell {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--maao-success);
    vertical-align: middle !important;
}

.grand-total-cell {
    font-size: 1.5em;
    font-weight: 800;
    color: var(--maao-text-primary);
}