:root {
    --ah-primary: #2c5f8a;
    --ah-primary-light: #3d7ba8;
    --ah-secondary: #f5f7fa;
    --ah-success: #27ae60;
    --ah-danger: #e74c3c;
    --ah-warning: #f39c12;
    --ah-text: #333;
    --ah-text-light: #666;
    --ah-border: #ddd;
    --ah-background: #fff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--ah-text);
    background-color: var(--ah-secondary);
    line-height: 1.6;
}

.ah-container {
    display: flex;
    min-height: 100vh;
}

.ah-navigation {
    width: 250px;
    background-color: var(--ah-primary);
    color: white;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.ah-nav-brand {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.ah-logo {
    background-color: rgba(255,255,255,0.2);
    width: 40px;
    height: 40px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 12px;
    font-size: 16px;
}

.ah-brand-text {
    font-size: 16px;
    font-weight: 600;
}

.ah-nav-menu {
    list-style: none;
}

.ah-nav-menu li {
    margin-bottom: 5px;
}

.ah-nav-link {
    display: block;
    padding: 12px 16px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.ah-nav-link:hover {
    background-color: rgba(255,255,255,0.1);
    color: white;
}

.ah-nav-logout {
    margin-top: 30px;
    border-top: 1px solid rgba(255,255,255,0.2);
    padding-top: 30px;
}

.ah-content {
    flex: 1;
    margin-left: 250px;
    padding: 30px;
    background-color: var(--ah-secondary);
}

.ah-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.ah-page-header h1 {
    font-size: 28px;
    color: var(--ah-primary);
    margin-bottom: 0;
}

.ah-header-actions {
    display: flex;
    gap: 10px;
}

.ah-form-container {
    background: var(--ah-background);
    padding: 30px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.ah-form {
    max-width: 100%;
}

.ah-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.ah-form-group {
    display: flex;
    flex-direction: column;
}

.ah-form-group label {
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--ah-text);
    font-size: 14px;
}

.ah-input, .ah-textarea, .ah-input-select {
    padding: 10px 12px;
    border: 1px solid var(--ah-border);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.ah-input:focus, .ah-textarea:focus, .ah-input-select:focus {
    outline: none;
    border-color: var(--ah-primary);
    box-shadow: 0 0 0 3px rgba(44, 95, 138, 0.1);
}

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

.ah-input-search {
    padding: 10px 12px;
    border: 1px solid var(--ah-border);
    border-radius: 4px;
    font-size: 14px;
    flex: 1;
}

.ah-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

.ah-form-inline {
    display: flex;
    gap: 10px;
    align-items: center;
}

.ah-search-box {
    background: var(--ah-background);
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.ah-form-search {
    display: flex;
    gap: 10px;
}

.ah-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.ah-btn-primary {
    background-color: var(--ah-primary);
    color: white;
}

.ah-btn-primary:hover {
    background-color: var(--ah-primary-light);
}

.ah-btn-secondary {
    background-color: #f0f0f0;
    color: var(--ah-text);
    border: 1px solid var(--ah-border);
}

.ah-btn-secondary:hover {
    background-color: #e0e0e0;
}

.ah-btn-success {
    background-color: var(--ah-success);
    color: white;
}

.ah-btn-success:hover {
    background-color: #229954;
}

.ah-btn-danger {
    background-color: var(--ah-danger);
    color: white;
}

.ah-btn-danger:hover {
    background-color: #c0392b;
}

.ah-btn-block {
    width: 100%;
}

.ah-btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.ah-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.ah-stat-card {
    background: var(--ah-background);
    padding: 20px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-left: 4px solid var(--ah-primary);
}

.ah-stat-card.ah-stat-danger {
    border-left-color: var(--ah-danger);
}

.ah-stat-label {
    font-size: 12px;
    color: var(--ah-text-light);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 10px;
}

.ah-stat-value {
    font-size: 28px;
    font-weight: bold;
    color: var(--ah-primary);
    margin-bottom: 8px;
}

.ah-stat-card.ah-stat-danger .ah-stat-value {
    color: var(--ah-danger);
}

.ah-stat-meta {
    font-size: 12px;
    color: var(--ah-text-light);
}

.ah-table-responsive {
    background: var(--ah-background);
    border-radius: 6px;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.ah-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.ah-table thead {
    background-color: #f5f5f5;
    border-bottom: 2px solid var(--ah-border);
}

.ah-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--ah-text);
}

.ah-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--ah-border);
}

.ah-table tbody tr:hover {
    background-color: #fafafa;
}

.ah-table-actions {
    display: flex;
    gap: 8px;
    white-space: nowrap;
}

.ah-table-sm td, .ah-table-sm th {
    padding: 8px 12px;
    font-size: 13px;
}

.ah-text-right {
    text-align: right;
}

.ah-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.ah-badge-draft {
    background-color: #e8e8e8;
    color: #666;
}

.ah-badge-confirmed {
    background-color: #e3f2fd;
    color: #1565c0;
}

.ah-badge-paid {
    background-color: #e8f5e9;
    color: #27ae60;
}

.ah-badge-overdue {
    background-color: #ffebee;
    color: #e74c3c;
}

.ah-badge-cancelled {
    background-color: #f3e5f5;
    color: #7b1fa2;
}

.ah-badge-sent {
    background-color: #fff3e0;
    color: #e65100;
}

.ah-badge-accepted {
    background-color: #e8f5e9;
    color: #27ae60;
}

.ah-badge-declined {
    background-color: #ffebee;
    color: #e74c3c;
}

.ah-badge-expired {
    background-color: #f3e5f5;
    color: #7b1fa2;
}

.ah-alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 20px;
    border-left: 4px solid var(--ah-primary);
}

.ah-alert-error {
    background-color: #ffebee;
    color: #c62828;
    border-left-color: var(--ah-danger);
}

.ah-alert-success {
    background-color: #e8f5e9;
    color: #1b5e20;
    border-left-color: var(--ah-success);
}

.ah-filter-bar {
    background: var(--ah-background);
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.ah-empty-state {
    text-align: center;
    padding: 40px 20px;
    background: var(--ah-background);
    border-radius: 6px;
    color: var(--ah-text-light);
}

.ah-empty-state-small {
    padding: 20px;
    text-align: center;
    color: var(--ah-text-light);
    font-size: 14px;
}

.ah-section-title {
    font-size: 16px;
    font-weight: 600;
    margin: 30px 0 20px 0;
    padding-top: 20px;
    border-top: 1px solid var(--ah-border);
    color: var(--ah-primary);
}

.ah-items-container {
    margin-bottom: 20px;
}

.ah-item-row {
    background: #f9f9f9;
    padding: 16px;
    border-radius: 4px;
    margin-bottom: 12px;
    border: 1px solid var(--ah-border);
}

.ah-col-1 { flex: 1; }
.ah-col-2 { flex: 2; }
.ah-col-4 { flex: 4; }
.ah-col-auto { flex: 0 0 auto; }

.ah-totals-section {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 4px;
    margin-top: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--ah-border);
}

.ah-total-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--ah-border);
    font-size: 14px;
}

.ah-total-row label {
    font-weight: 500;
}

.ah-total-row-main {
    border-bottom: 2px solid var(--ah-primary);
    font-size: 16px;
    font-weight: 600;
    padding: 12px 0;
    margin-top: 8px;
}

.ah-auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--ah-primary) 0%, var(--ah-primary-light) 100%);
    padding: 20px;
}

.ah-auth-container {
    background: var(--ah-background);
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 400px;
}

.ah-auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.ah-auth-header h1 {
    font-size: 24px;
    color: var(--ah-primary);
    margin-bottom: 8px;
}

.ah-auth-header p {
    color: var(--ah-text-light);
    font-size: 14px;
}

.ah-login-form .ah-form-group,
.ah-register-form .ah-form-group {
    margin-bottom: 20px;
}

.ah-auth-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--ah-border);
    font-size: 14px;
}

.ah-auth-footer a {
    color: var(--ah-primary);
    text-decoration: none;
    font-weight: 500;
}

.ah-auth-footer a:hover {
    text-decoration: underline;
}

.ah-invoice-view, .ah-quote-view {
    background: var(--ah-background);
    padding: 30px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.ah-invoice-header, .ah-quote-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--ah-border);
}

.ah-invoice-client, .ah-quote-client {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 4px;
}

.ah-invoice-client h3, .ah-quote-client h3 {
    margin-bottom: 10px;
    color: var(--ah-primary);
}

.ah-invoice-client p, .ah-quote-client p {
    font-size: 13px;
    margin-bottom: 5px;
}

.ah-invoice-totals, .ah-quote-totals {
    margin-top: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 4px;
    width: fit-content;
}

.ah-invoice-notes, .ah-quote-notes {
    margin-top: 30px;
    padding: 20px;
    background: #fffacd;
    border-radius: 4px;
    border-left: 4px solid var(--ah-warning);
}

.ah-invoice-notes h4, .ah-quote-notes h4 {
    margin-bottom: 10px;
}

.ah-logo-preview {
    margin-top: 20px;
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.ah-logo-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 4px;
    border: 1px solid var(--ah-border);
}

.ah-dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.ah-dashboard-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ah-dashboard-card {
    background: var(--ah-background);
    padding: 20px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.ah-dashboard-card h3 {
    margin-bottom: 16px;
    font-size: 16px;
    color: var(--ah-primary);
}

.ah-row-danger {
    background-color: #ffebee;
}

.ah-client-select, .ah-item-description, .ah-item-quantity,
.ah-item-unit, .ah-item-price, .ah-item-vat, .ah-item-total {
    width: 100%;
}

.ah-remove-item {
    margin-top: auto;
}

.ah-action-box {
    margin-top: 30px;
    padding: 20px;
    background: #e3f2fd;
    border-radius: 4px;
    text-align: center;
    border: 1px solid #bbdefb;
}

.ah-convert-to-invoice {
    background-color: var(--ah-success);
    color: white;
}

.ah-convert-to-invoice:hover {
    background-color: #229954;
}

.ah-info-block h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
}

.ah-info-block p {
    font-size: 13px;
    margin-bottom: 4px;
}

.ah-date-item {
    display: flex;
    justify-content: space-between;
}

@media (max-width: 768px) {
    .ah-navigation {
        width: 100%;
        height: auto;
        position: relative;
        padding: 15px;
    }

    .ah-content {
        margin-left: 0;
        padding: 15px;
    }

    .ah-form-row {
        grid-template-columns: 1fr;
    }

    .ah-stats-grid {
        grid-template-columns: 1fr;
    }

    .ah-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .ah-table {
        font-size: 12px;
    }

    .ah-table th, .ah-table td {
        padding: 8px;
    }

    .ah-dashboard-grid {
        grid-template-columns: 1fr;
    }

    .ah-table-actions {
        flex-direction: column;
        gap: 5px;
    }

    .ah-btn-sm {
        width: 100%;
    }
}

/* =============================================
   WordPress theme overrides for Arvete Haldus
   ============================================= */

/* Hide WP theme header (Invoice + breadcrumb) */
body.page .wp-site-blocks > header.wp-block-template-part {
    display: none !important;
}

/* Hide WP page title "Arvete haldus" */
body.page h1.wp-block-post-title {
    display: none !important;
}

/* Hide WP theme footer (Invoice + Blog/About/FAQs etc.) */
body.page .wp-site-blocks > footer.wp-block-template-part {
    display: none !important;
}

/* Remove WP admin bar spacing for plugin navigation */
body.admin-bar .ah-navigation {
    top: 32px;
    height: calc(100vh - 32px);
}

/* Remove WP theme padding/margins around plugin content */
body.page .wp-site-blocks > main {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
}

body.page .wp-site-blocks > main > .wp-block-group {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
}

body.page .wp-site-blocks > main .wp-block-post-content {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
}

body.page .wp-site-blocks {
    padding-top: 0 !important;
    min-height: 100vh;
}

/* Break out of WP is-layout-constrained max-width (645px content-size) */
.ah-container {
    max-width: 100% !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Also override for login/register/setup forms */
.ah-login-container,
.ah-register-container,
.ah-setup-container {
    max-width: 420px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* =============================================
   Compact layout — no scroll on desktop
   ============================================= */

.ah-container {
    min-height: calc(100vh - 32px); /* account for admin bar */
}

.ah-navigation {
    padding: 15px;
}

.ah-nav-brand {
    margin-bottom: 15px;
    padding-bottom: 12px;
}

.ah-nav-link {
    padding: 10px 14px;
}

.ah-nav-logout {
    margin-top: 15px;
    padding-top: 15px;
}

.ah-content {
    padding: 20px 25px;
}

.ah-page-header {
    margin-bottom: 15px;
}

.ah-page-header h1 {
    font-size: 22px;
}

/* Dashboard stats — always in a single row */
.ah-stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.ah-stat-card {
    padding: 14px 16px;
}

.ah-stat-label {
    font-size: 11px;
    margin-bottom: 5px;
}

.ah-stat-value {
    font-size: 22px;
    margin-bottom: 4px;
}

.ah-stat-meta {
    font-size: 11px;
}

/* Dashboard grid — compact */
.ah-dashboard-grid {
    gap: 15px;
}

.ah-dashboard-card {
    padding: 14px 16px;
}

.ah-dashboard-card h3 {
    margin-bottom: 10px;
    font-size: 15px;
}

/* Tables — compact */
.ah-table th, .ah-table td {
    padding: 8px 12px;
}

.ah-search-box {
    padding: 14px;
    margin-bottom: 15px;
}

.ah-filter-bar {
    padding: 14px;
    margin-bottom: 15px;
}

.ah-empty-state {
    padding: 20px 15px;
}

.ah-empty-state-small {
    padding: 12px;
}

/* Form — slightly more compact */
.ah-form-container {
    padding: 20px;
}

.ah-form-row {
    gap: 15px;
    margin-bottom: 15px;
}

.ah-form-group label {
    margin-bottom: 5px;
    font-size: 13px;
}

.ah-input, .ah-textarea, .ah-input-select {
    padding: 8px 10px;
    font-size: 13px;
}

.ah-textarea {
    min-height: 80px;
}

.ah-form-actions {
    margin-top: 20px;
}

@media print {
    .ah-navigation,
    .ah-page-header,
    .ah-form-container,
    .ah-search-box,
    .ah-filter-bar,
    .ah-header-actions,
    .ah-form-actions,
    .ah-table-actions {
        display: none;
    }

    .ah-content {
        margin-left: 0;
        padding: 0;
    }

    body {
        background: white;
    }
}