/**
 * SERP Preview Tool - Main Styles
 * Google Material Design-inspired styling
 */

/* CSS Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background-color: #f8f9fa;
    color: #202124;
    line-height: 1.5;
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: #fff;
    border-bottom: 1px solid #dadce0;
    padding: 16px 24px;
    margin-bottom: 24px;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1400px;
    margin: 0 auto;
}

.header-logo {
    flex-shrink: 0;
}

.header-logo svg {
    display: block;
}

.header-text h1 {
    font-size: 22px;
    font-weight: 400;
    color: #202124;
}

.header-text p {
    font-size: 14px;
    color: #5f6368;
    margin-top: 4px;
}

/* Main Layout */
.main-content {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Cards */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
    padding: 24px;
}

.card-title {
    font-size: 16px;
    font-weight: 500;
    color: #202124;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e8eaed;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #202124;
    margin-bottom: 8px;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid #dadce0;
    border-radius: 4px;
    background: #fff;
    color: #202124;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: #9aa0a6;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Character Counter */
.char-counter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 12px;
}

.char-count {
    color: #5f6368;
}

.char-count.good {
    color: #188038;
}

.char-count.warning {
    color: #f9ab00;
}

.char-count.danger {
    color: #d93025;
}

.char-limit {
    color: #9aa0a6;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.btn-primary {
    background-color: #1a73e8;
    color: #fff;
}

.btn-primary:hover {
    background-color: #1557b0;
    box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
}

.btn-primary:active {
    background-color: #174ea6;
}

.btn-secondary {
    background-color: #fff;
    color: #1a73e8;
    border: 1px solid #dadce0;
}

.btn-secondary:hover {
    background-color: #f8f9fa;
    border-color: #d2e3fc;
}

.btn-icon {
    width: 20px;
    height: 20px;
}

/* Rich Snippet Selector */
.snippet-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.snippet-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #5f6368;
    background: #f1f3f4;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.snippet-btn:hover {
    background: #e8eaed;
}

.snippet-btn.active {
    background: #e8f0fe;
    color: #1a73e8;
}

/* Rich Snippet Panels */
.snippet-panel {
    display: none;
    padding-top: 16px;
    border-top: 1px solid #e8eaed;
    margin-top: 16px;
}

.snippet-panel.active {
    display: block;
}

/* FAQ Input */
.faq-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.faq-item-input {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 16px;
    position: relative;
}

.faq-item-input .remove-faq {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: #5f6368;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 4px;
}

.faq-item-input .remove-faq:hover {
    color: #d93025;
}

.add-faq-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 13px;
    color: #1a73e8;
    background: none;
    border: 1px dashed #dadce0;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    justify-content: center;
}

.add-faq-btn:hover {
    background: #f8f9fa;
    border-color: #1a73e8;
}

/* Rating Input */
.rating-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Sitelinks Input */
.sitelinks-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Breadcrumb Input */
.breadcrumb-input-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.breadcrumb-item-input {
    display: flex;
    gap: 8px;
    align-items: center;
}

.breadcrumb-item-input input {
    flex: 1;
}

.breadcrumb-item-input .remove-breadcrumb {
    background: none;
    border: none;
    color: #5f6368;
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}

.breadcrumb-item-input .remove-breadcrumb:hover {
    color: #d93025;
}

/* Preview Section */
.preview-section {
    background: #fff;
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e8eaed;
    background: #f8f9fa;
}

.preview-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 24px;
}

/* Device Toggle */
.device-toggle {
    display: flex;
    background: #e8eaed;
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}

.device-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #5f6368;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.device-toggle-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.device-toggle-btn:hover {
    color: #202124;
    background: rgba(255, 255, 255, 0.5);
}

.device-toggle-btn.active {
    color: #1a73e8;
    background: #fff;
    box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15);
}

/* Mobile Preview Container */
.serp-preview-mobile {
    max-width: 100%;
    display: flex;
    justify-content: center;
}

.serp-preview-mobile > div {
    max-width: 420px;
    width: 100%;
}

.preview-title {
    font-size: 16px;
    font-weight: 500;
    color: #202124;
}

/* Export Actions */
.export-actions {
    display: flex;
    gap: 8px;
}

.export-actions .btn {
    padding: 6px 12px;
    font-size: 13px;
}

.export-actions .btn-icon {
    width: 16px;
    height: 16px;
}

/* Notifications */
.notification {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: #323232;
    color: #fff;
    border-radius: 4px;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.notification.show {
    opacity: 1;
}

.notification.success {
    background: #188038;
}

.notification.error {
    background: #d93025;
}

/* Loading State */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-muted {
    color: #5f6368;
}

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

.mt-16 {
    margin-top: 16px;
}

/* Header Actions */
.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #5f6368;
    cursor: pointer;
    transition: background-color 0.2s;
}

.icon-btn:hover {
    background: #f1f3f4;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

/* Input with Button */
.input-with-button {
    display: flex;
    gap: 8px;
}

.input-with-button .form-input {
    flex: 1;
}

.input-with-button .btn {
    flex-shrink: 0;
    padding: 10px 16px;
}

/* Form Hint */
.form-hint {
    display: block;
    font-size: 12px;
    color: #5f6368;
    margin-top: 6px;
}

/* Form Divider */
.form-divider {
    height: 1px;
    background: #e8eaed;
    margin: 20px 0;
}

/* Additional Options */
.option-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 8px 0;
}

.option-row:last-child {
    margin-bottom: 0;
}

.form-label-small {
    font-size: 13px;
    color: #5f6368;
    min-width: 120px;
    flex-shrink: 0;
}

.form-input-small {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
}

/* Date Prefix Wrapper */
.date-prefix-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.form-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #1a73e8;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 24px 38px 3px rgba(0,0,0,.14), 0 9px 46px 8px rgba(0,0,0,.12), 0 11px 15px -7px rgba(0,0,0,.2);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #e8eaed;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 500;
    color: #202124;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #5f6368;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: #202124;
}

.modal-body {
    padding: 24px;
}

.modal-body p {
    margin-bottom: 16px;
    color: #5f6368;
}

.share-link-wrapper {
    display: flex;
    gap: 8px;
}

.share-link-wrapper .form-input {
    flex: 1;
}

/* ===========================================
   DARK MODE
   =========================================== */
body.dark-mode {
    background-color: #202124;
    color: #e8eaed;
}

body.dark-mode .header {
    background: #292a2d;
    border-bottom-color: #3c4043;
}

body.dark-mode .header-text h1 {
    color: #e8eaed;
}

body.dark-mode .header-text p {
    color: #9aa0a6;
}

body.dark-mode .icon-btn {
    color: #9aa0a6;
}

body.dark-mode .icon-btn:hover {
    background: #3c4043;
}

body.dark-mode .card {
    background: #292a2d;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
}

body.dark-mode .card-title {
    color: #e8eaed;
    border-bottom-color: #3c4043;
}

body.dark-mode .form-label {
    color: #e8eaed;
}

body.dark-mode .form-input,
body.dark-mode .form-textarea {
    background: #202124;
    border-color: #3c4043;
    color: #e8eaed;
}

body.dark-mode .form-input:focus,
body.dark-mode .form-textarea:focus {
    border-color: #8ab4f8;
    box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.2);
}

body.dark-mode .form-input::placeholder,
body.dark-mode .form-textarea::placeholder {
    color: #9aa0a6;
}

body.dark-mode .form-hint {
    color: #9aa0a6;
}

body.dark-mode .form-divider {
    background: #3c4043;
}

body.dark-mode .form-label-small {
    color: #9aa0a6;
}

body.dark-mode .char-limit {
    color: #9aa0a6;
}

body.dark-mode .snippet-btn {
    background: #3c4043;
    color: #9aa0a6;
}

body.dark-mode .snippet-btn:hover {
    background: #4a4b4e;
}

body.dark-mode .snippet-btn.active {
    background: #394457;
    color: #8ab4f8;
}

body.dark-mode .snippet-panel {
    border-top-color: #3c4043;
}

body.dark-mode .faq-item-input {
    background: #202124;
}

body.dark-mode .add-faq-btn {
    color: #8ab4f8;
    border-color: #3c4043;
}

body.dark-mode .add-faq-btn:hover {
    background: #3c4043;
    border-color: #8ab4f8;
}

body.dark-mode .preview-section {
    background: #292a2d;
}

body.dark-mode .preview-header {
    background: #202124;
    border-bottom-color: #3c4043;
}

body.dark-mode .device-toggle {
    background: #3c4043;
}

body.dark-mode .device-toggle-btn {
    color: #9aa0a6;
}

body.dark-mode .device-toggle-btn:hover {
    color: #e8eaed;
    background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .device-toggle-btn.active {
    color: #8ab4f8;
    background: #292a2d;
}

body.dark-mode .btn-secondary {
    background: #292a2d;
    color: #8ab4f8;
    border-color: #3c4043;
}

body.dark-mode .btn-secondary:hover {
    background: #3c4043;
    border-color: #5f6368;
}

body.dark-mode .modal-content {
    background: #292a2d;
}

body.dark-mode .modal-header {
    border-bottom-color: #3c4043;
}

body.dark-mode .modal-header h3 {
    color: #e8eaed;
}

body.dark-mode .modal-close {
    color: #9aa0a6;
}

body.dark-mode .modal-close:hover {
    color: #e8eaed;
}

body.dark-mode .modal-body p {
    color: #9aa0a6;
}

body.dark-mode .notification {
    background: #3c4043;
}

/* Dark mode icon toggle */
body.dark-mode .icon-sun {
    display: none;
}

body.dark-mode .icon-moon {
    display: block !important;
}

.icon-moon {
    display: none;
}

/* ===========================================
   AI SUGGESTIONS
   =========================================== */

/* AI Suggestions Button */
.ai-suggestions-group {
    margin-top: 16px;
}

.btn-accent {
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: #fff;
    border: none;
}

.btn-accent:hover {
    background: linear-gradient(135deg, #6d28d9 0%, #9333ea 100%);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4);
}

.btn-accent:active {
    background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 100%);
}

.btn-accent.loading {
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    opacity: 0.7;
}

/* AI Comparison Modal */
.ai-comparison {
    max-width: 700px;
}

.comparison-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid #e8eaed;
}

.comparison-section:last-of-type {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.comparison-section h4 {
    font-size: 14px;
    font-weight: 500;
    color: #202124;
    margin-bottom: 12px;
}

.comparison-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 12px;
}

.comparison-column {
    padding: 12px;
    border-radius: 8px;
}

.comparison-column.original {
    background: #f8f9fa;
    border: 1px solid #e8eaed;
}

.comparison-column.suggested {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.comparison-column label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #5f6368;
    margin-bottom: 8px;
}

.comparison-column.suggested label {
    color: #16a34a;
}

.comparison-column p {
    font-size: 14px;
    line-height: 1.5;
    color: #202124;
    word-break: break-word;
    margin: 0;
}

.btn-accept {
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #16a34a;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-accept:hover {
    background: #dcfce7;
    border-color: #86efac;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e8eaed;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .comparison-row {
        grid-template-columns: 1fr;
    }
}

/* Dark mode styles for AI suggestions */
body.dark-mode .btn-accent {
    background: linear-gradient(135deg, #8b5cf6 0%, #a855f7 100%);
}

body.dark-mode .btn-accent:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

body.dark-mode .comparison-section {
    border-bottom-color: #3c4043;
}

body.dark-mode .comparison-section h4 {
    color: #e8eaed;
}

body.dark-mode .comparison-column.original {
    background: #202124;
    border-color: #3c4043;
}

body.dark-mode .comparison-column.suggested {
    background: #132b1e;
    border-color: #166534;
}

body.dark-mode .comparison-column label {
    color: #9aa0a6;
}

body.dark-mode .comparison-column.suggested label {
    color: #4ade80;
}

body.dark-mode .comparison-column p {
    color: #e8eaed;
}

body.dark-mode .btn-accept {
    color: #4ade80;
    background: #132b1e;
    border-color: #166534;
}

body.dark-mode .btn-accept:hover {
    background: #14532d;
    border-color: #22c55e;
}

body.dark-mode .modal-actions {
    border-top-color: #3c4043;
}
