/**
 * Keyword Position Checker Pro - Complete Dark Professional Design
 * Version: 4.1 Responsive Edition
 * Author: Moritz Martin
 */

/* Reset and Base Styles */
* {
    box-sizing: border-box;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Skip Links for Accessibility */
.keyword-checker-skip-link {
    position: absolute !important;
    clip: rect(1px, 1px, 1px, 1px) !important;
    padding: 0 !important;
    border: 0 !important;
    height: 1px !important;
    width: 1px !important;
    overflow: hidden !important;
}

.keyword-checker-skip-link:focus {
    position: static !important;
    clip: auto !important;
    height: auto !important;
    width: auto !important;
    overflow: visible !important;
    padding: 1rem !important;
    background: #22c55e !important;
    color: white !important;
    text-decoration: none !important;
    z-index: 999999 !important;
    font-weight: bold !important;
}

/* Screen Reader Only */
.sr-only,
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Live Region for Screen Readers */
.sr-live {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Main Container */
.keyword-checker-container { 
    max-width: 1320px; 
    width: 100%;
    margin: 2rem auto; 
    background: #1e293b;
    color: #ffffff; 
    border-radius: 16px; 
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Header Section with Green Gradient */
.keyword-checker-container header,
.keyword-checker-container .header {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    padding: 2rem;
    text-align: center;
    position: relative;
}

.keyword-checker-container header::before,
.keyword-checker-container .header::before {
    content: none;
    position: absolute;
    top: 0.75rem;
    right: 1.5rem;
    font-size: 0.7rem;
    opacity: 0.8;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: rgba(255, 255, 255, 0.9);
}

/* Main Title */
.keyword-checker-container h1 {
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    color: white;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    line-height: 1.2;
}

.keyword-checker-container h1::before {
    content: none;
    margin-right: 0.5rem;
    font-size: 2rem;
}

/* Description Text */
.description {
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.6;
    font-size: 1.05rem;
    margin: 1rem 0 0 0;
    font-weight: 400;
}

/* Form Container */
.keyword-checker-form {
    padding: 2.5rem;
}

.keyword-checker-form-actual {
    width: 100%;
}

/* Form Elements */
.input-fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

.input-group {
    margin-bottom: 2rem;
}

/* Input Labels */
.input-label { 
    color: #ffffff; 
    display: block; 
    margin-bottom: 0.75rem; 
    font-weight: 600;
    font-size: 1rem;
}

.input-label::after {
    content: " *";
    color: #ef4444;
    margin-left: 0.25rem;
}

.input-label.optional::after {
    content: " (optional)";
    color: #94a3b8;
    font-weight: normal;
    font-size: 0.9rem;
}

/* Input Fields */
.keyword-input, 
.domain-input, 
.email-input, 
.tld-select { 
    width: 100%; 
    padding: 1.1rem;
    background: #334155; 
    color: #ffffff; 
    border: 2px solid #475569; 
    border-radius: 12px;
    font-size: 16px; /* verhindert Zoom auf iOS */
    transition: all 0.3s ease;
    box-sizing: border-box;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* Placeholder Styles */
.keyword-input::placeholder,
.domain-input::placeholder,
.email-input::placeholder {
    color: #94a3b8;
    opacity: 1;
}

/* Focus States */
.keyword-input:focus, 
.domain-input:focus, 
.email-input:focus, 
.tld-select:focus {
    border-color: #22c55e;
    background: #3f4f63;
    outline: none;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

/* Select Arrow for TLD Select */
.tld-select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E");
    background-position: right 1rem center;
    background-repeat: no-repeat;
    background-size: 1rem;
    padding-right: 3rem;
}

/* Error States */
.input-error {
    border-color: #f59e0b !important;
    background: #451a03 !important;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2) !important;
}

.error-text {
    color: #fbbf24;
    font-size: 0.875rem;
    margin-top: 0.75rem;
    display: flex;
    align-items: flex-start;
    padding: 0.75rem 1rem;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 8px;
    border-left: 4px solid #f59e0b;
    line-height: 1.4;
}

.error-text::before {
    content: "⚠️";
    margin-right: 0.75rem;
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

/* Submit Button */
.check-button { 
    width: 100%; 
    padding: 1.4rem 2rem; 
    background: linear-gradient(135deg, #22c55e, #16a34a); 
    color: white; 
    border: none; 
    border-radius: 12px; 
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer; 
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(34, 197, 94, 0.3);
    margin-top: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    overflow: hidden;
    min-height: 56px;
}

.check-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s ease;
}

.check-button:hover::before {
    left: 100%;
}

.check-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 35px rgba(34, 197, 94, 0.4);
    background: linear-gradient(135deg, #16a34a, #15803d);
}

.check-button:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
}

.check-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    pointer-events: none;
}

.check-button:disabled:hover {
    transform: none;
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

/* Button Text and Loading States */
.button-text {
    position: relative;
    z-index: 1;
}

.loading-spinner {
    display: none;
}

/* Results Section */
.result-message {
    margin-top: 2rem;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    animation: fadeInUp 0.5s ease-out;
}

.result-success {
    background: linear-gradient(135deg, #059669, #047857);
    border: 1px solid #10b981;
    color: white;
}

.result-warning {
    background: linear-gradient(135deg, #d97706, #b45309);
    border: 1px solid #f59e0b;
    color: white;
}

.result-error {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    border: 1px solid #ef4444;
    color: white;
}

.position-message {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.error-message {
    font-size: 1.1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border-left: 4px solid currentColor;
    text-align: center;
}

/* Results Table Wrapper (responsive) */
.results-table {
    margin-top: 2rem;
    width: 100%;
    overflow-x: auto;                 /* horizontales Scrollen bei kleinen Screens */
    -webkit-overflow-scrolling: touch;
}

/* Results Table */
.results-table table {
    width: 100%;
    border-collapse: collapse;
    background: #334155;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    min-width: 640px;                 /* genug Breite für alle Spalten */
}

.results-table caption {
    padding: 1.25rem;
    font-weight: 600;
    color: #e2e8f0;
    text-align: left;
    background: #475569;
    font-size: 1rem;
}

.results-table th {
    background: #475569;
    color: #e2e8f0;
    padding: 1.1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #64748b;
}

.results-table td {
    padding: 1.1rem;
    border-bottom: 1px solid #475569;
    vertical-align: top;
    color: #e2e8f0;
}

.results-table tr:last-child td {
    border-bottom: none;
}

.results-table tr:hover {
    background: rgba(34, 197, 94, 0.1);
}

.results-table tr.target-domain {
    background: rgba(34, 197, 94, 0.15);
    border-left: 4px solid #22c55e;
}

.results-table tr.target-domain td {
    background: transparent;
}

/* Position Badge */
.results-table .position {
    background: #3b82f6;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    display: inline-block;
    min-width: 3rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.results-table .target-domain .position {
    background: #22c55e;
    animation: glow 2s ease-in-out infinite alternate;
}

/* Meta Information in Table */
.meta-title {
    font-weight: 600;
    color: #f1f5f9;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    font-size: 1rem;
}

.meta-description {
    font-size: 0.9rem;
    color: #cbd5e1;
    line-height: 1.5;
    margin: 0;
}

.domain {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    color: #22c55e;
    font-size: 0.85rem;
    font-weight: 600;
    word-break: break-all;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes glow {
    from {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 5px #22c55e;
    }
    to {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 20px #22c55e, 0 0 30px #22c55e;
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Responsive Design - Mobile First */
@media (max-width: 480px) {
    .keyword-checker-container {
        margin: 1rem;
        border-radius: 12px;
    }
    
    .keyword-checker-container header,
    .keyword-checker-container .header {
        padding: 1.4rem 1rem;
    }
    
    .keyword-checker-container h1 {
        font-size: 1.7rem;
    }
    
    .keyword-checker-container header::before,
    .keyword-checker-container .header::before {
        font-size: 0.6rem;
        top: 0.5rem;
        right: 1rem;
    }
    
    .keyword-checker-form {
        padding: 1.5rem 1.25rem;
    }
    
    .description {
        font-size: 0.95rem;
    }
    
    .input-group {
        margin-bottom: 1.4rem;
    }
    
    .keyword-input, 
    .domain-input, 
    .email-input, 
    .tld-select {
        padding: 0.95rem;
        font-size: 16px;
    }
    
    .check-button {
        padding: 1.2rem;
        font-size: 1rem;
    }
    
    .position-message {
        font-size: 1.2rem;
    }

    .result-message {
        padding: 1.5rem;
    }

    .results-table th,
    .results-table td {
        padding: 0.75rem;
        font-size: 0.85rem;
    }

    .meta-title {
        font-size: 0.95rem;
    }

    .meta-description {
        font-size: 0.8rem;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .keyword-checker-container {
        margin: 1.5rem;
    }
    
    .keyword-checker-container header,
    .keyword-checker-container .header {
        padding: 2rem 1.5rem;
    }
    
    .keyword-checker-form {
        padding: 2rem 1.75rem;
    }
    
    .keyword-checker-container h1 {
        font-size: 2.1rem;
    }
}

/* Focus Management and Accessibility */
*:focus {
    outline: 2px solid #22c55e;
    outline-offset: 2px;
}

.keyword-input:focus,
.domain-input:focus,
.email-input:focus,
.tld-select:focus,
.check-button:focus {
    outline: none;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .keyword-checker-container {
        border: 3px solid #22c55e;
    }
    
    .keyword-input, 
    .domain-input, 
    .email-input, 
    .tld-select {
        border-width: 3px;
    }
    
    .check-button {
        border: 2px solid #ffffff;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .check-button::before {
        display: none;
    }
    
    .results-table .target-domain .position {
        animation: none;
    }
}

/* Print Styles */
@media print {
    .keyword-checker-container {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        margin: 0 !important;
        border: 2px solid #000 !important;
    }
    
    .keyword-checker-container header,
    .keyword-checker-container .header {
        background: #f0f0f0 !important;
        color: black !important;
    }
    
    .check-button {
        display: none !important;
    }
    
    .results-table table {
        background: white !important;
        color: black !important;
    }
    
    .results-table th {
        background: #f0f0f0 !important;
        color: black !important;
    }
    
    .position {
        background: #f0f0f0 !important;
        color: black !important;
        border: 1px solid #000 !important;
    }
}

/* Utility Classes */
.text-center {
    text-align: center !important;
}

.font-bold {
    font-weight: bold !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

/* Focus Within Enhancement */
.keyword-checker-container:focus-within {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(34, 197, 94, 0.3);
}

/* Custom Scrollbar for Webkit Browsers */
.results-table::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.results-table::-webkit-scrollbar-track {
    background: #475569;
    border-radius: 4px;
}

.results-table::-webkit-scrollbar-thumb {
    background: #22c55e;
    border-radius: 4px;
}

.results-table::-webkit-scrollbar-thumb:hover {
    background: #16a34a;
}

/* === KPC 4.3 Responsive Cost Guard Overrides === */
.keyword-checker-container,
.keyword-checker-container * { box-sizing: border-box; }
.keyword-checker-container { width: min(1040px, calc(100% - 32px)); max-width: 1040px; margin: clamp(16px, 4vw, 44px) auto; border-radius: clamp(18px, 3vw, 28px); overflow: hidden; }
.keyword-checker-container header,
.keyword-checker-container .header { padding: clamp(24px, 5vw, 52px) clamp(18px, 5vw, 56px); margin: 0; border-radius: 0; text-align: left; }
.keyword-checker-container h1 { font-size: clamp(1.72rem, 4.6vw, 3.35rem); letter-spacing: -0.04em; }
.keyword-checker-form { padding: clamp(18px, 4vw, 44px); }
.keyword-checker-form-actual .input-fieldset { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(14px, 2.4vw, 22px); }
.keyword-checker-form-actual .input-group { min-width: 0; margin-bottom: 0; }
.keyword-checker-form-actual .input-group:nth-child(1),
.keyword-checker-form-actual .input-group:nth-child(3) { grid-column: span 2; }
.keyword-input, .domain-input, .email-input, .tld-select { min-height: 56px; width: 100%; max-width: 100%; border-radius: 16px; }
.check-button { margin-top: clamp(18px, 3vw, 28px); min-height: 62px; border-radius: 18px; }
.kpc-mini-note { color: #86efac; font-size: .88rem; margin-top: .45rem; display: inline-block; }
.kpc-cache-note { color: #93c5fd; }
.kpc-stale-note, .kpc-quota-note { color: #fde68a; }
.results-table { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 18px; }
.results-table table { width: 100%; min-width: 760px; table-layout: fixed; }
.results-table th, .results-table td { overflow-wrap: anywhere; word-break: break-word; }
@media (max-width: 760px) {
  .keyword-checker-container { width: calc(100% - 20px); margin: 10px auto 24px; border-radius: 20px; }
  .keyword-checker-container header, .keyword-checker-container .header { padding: 34px 18px 22px; }
  .keyword-checker-form { padding: 16px; }
  .keyword-checker-form-actual .input-fieldset { grid-template-columns: 1fr; gap: 14px; }
  .keyword-checker-form-actual .input-group:nth-child(1), .keyword-checker-form-actual .input-group:nth-child(3) { grid-column: auto; }
  .keyword-input, .domain-input, .email-input, .tld-select { min-height: 54px; padding: 14px 15px; font-size: 16px; }
  .check-button { min-height: 58px; padding: 15px 18px; font-size: 1rem; }
  .results-table { overflow: visible; background: transparent; }
  .results-table table, .results-table thead, .results-table tbody, .results-table th, .results-table td, .results-table tr { display: block; width: 100%; min-width: 0; }
  .results-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .results-table tr { margin: 0 0 12px; padding: 14px; border-radius: 16px; }
  .results-table td { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 10px; padding: 9px 0; border: 0; text-align: left; }
  .results-table td::before { content: attr(data-label); color: #94a3b8; font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
}
@media (max-width: 420px) {
  .keyword-checker-container { width: calc(100% - 12px); border-radius: 16px; }
  .keyword-checker-container h1 { font-size: clamp(1.45rem, 9vw, 1.9rem); }
  .results-table td { grid-template-columns: 1fr; gap: 4px; }
}


/* Final frontend layout */
.keyword-checker-container {
    width: 100% !important;
    max-width: min(1320px, calc(100vw - 48px)) !important;
    margin: clamp(22px, 4vw, 52px) auto !important;
}
.keyword-checker-container header::before,
.keyword-checker-container .header::before {
    content: none !important;
    display: none !important;
}
.keyword-checker-form {
    padding: clamp(26px, 4vw, 56px) !important;
}
.keyword-checker-form-actual .input-fieldset {
    gap: clamp(20px, 2.8vw, 34px) !important;
}
@media (max-width: 900px) {
    .keyword-checker-container {
        max-width: calc(100vw - 28px) !important;
    }
}
@media (max-width: 440px) {
    .keyword-checker-container {
        max-width: calc(100vw - 16px) !important;
    }
}


/* Elementor & full-width layout overrides */
.elementor-widget-shortcode .elementor-widget-container,
.elementor-widget-shortcode .elementor-shortcode,
.elementor-shortcode,
.wp-block-shortcode {
    width: 100% !important;
    max-width: 100% !important;
}
.elementor-widget-shortcode .keyword-checker-container,
.elementor-shortcode .keyword-checker-container,
.wp-block-shortcode .keyword-checker-container,
.keyword-checker-container {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}
.keyword-checker-container h1::before,
.keyword-checker-container h2::before {
    content: none !important;
}
.rate-limit-notice,
.kpc-cache-note {
    display: none !important;
}
.keyword-checker-form-actual .input-fieldset {
    gap: clamp(22px, 3vw, 38px) !important;
}
.keyword-checker-form {
    padding: clamp(28px, 4.2vw, 64px) !important;
}
.keyword-input,
.domain-input,
.email-input,
.tld-select {
    min-height: 62px !important;
}
@media (max-width: 900px) {
    .keyword-checker-container { width: 100% !important; max-width: 100% !important; }
}
