/**
 * Grammar Checker Styles for Docs App
 * Cloned from web app's Editor component
 */

/* ════════════════════════════════════════════════════════════════════════════
   GRAMMAR PANEL - Fixed Right Sidebar
   ════════════════════════════════════════════════════════════════════════════ */

.grammar-panel {
    position: fixed;
    top: 80px;
    /* Below toolbar */
    right: 16px;
    width: 320px;
    max-height: calc(100vh - 100px);
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    font-family: 'Inter', 'Noto Sans Tamil', sans-serif;
}

.grammar-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #f8fafc 0%, #fff 100%);
}

.grammar-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 16px;
    color: #111827;
}

.grammar-panel-title svg {
    color: #8b5cf6;
}

.grammar-panel-close {
    width: 28px;
    height: 28px;
    border: none;
    background: #f3f4f6;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: all 0.2s;
}

.grammar-panel-close:hover {
    background: #e5e7eb;
    color: #374151;
}

.grammar-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* ════════════════════════════════════════════════════════════════════════════
   ANALYZE BUTTON
   ════════════════════════════════════════════════════════════════════════════ */

.grammar-analyze-btn {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
    margin-bottom: 16px;
}

.grammar-analyze-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.grammar-analyze-btn:active {
    transform: scale(0.98);
}

.grammar-analyze-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ════════════════════════════════════════════════════════════════════════════
   SCORE AND TONE CARDS
   ════════════════════════════════════════════════════════════════════════════ */

.grammar-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.grammar-stat-card {
    padding: 14px;
    background: #f9fafb;
    border-radius: 12px;
    border: 1px solid #f3f4f6;
}

.grammar-stat-label {
    font-size: 10px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.grammar-stat-value {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.grammar-score {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.grammar-score.high {
    color: #10b981;
}

.grammar-score.medium {
    color: #f59e0b;
}

.grammar-score.low {
    color: #ef4444;
}

.grammar-score-suffix {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: 4px;
}

.grammar-tone {
    display: flex;
    align-items: center;
    gap: 8px;
}

.grammar-tone-emoji {
    font-size: 20px;
}

.grammar-tone-text {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

/* ════════════════════════════════════════════════════════════════════════════
   SUGGESTIONS SECTION
   ════════════════════════════════════════════════════════════════════════════ */

.grammar-suggestions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.grammar-suggestions-title {
    font-weight: 600;
    font-size: 14px;
    color: #374151;
}

.grammar-suggestions-count {
    font-size: 11px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 999px;
}

.grammar-suggestions-count.has-issues {
    background: #fef3c7;
    color: #d97706;
}

.grammar-suggestions-count.all-good {
    background: #d1fae5;
    color: #059669;
}

.grammar-accept-all {
    font-size: 12px;
    font-weight: 500;
    color: #8b5cf6;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.grammar-accept-all:hover {
    background: #f3f0ff;
    text-decoration: underline;
}

.grammar-suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ════════════════════════════════════════════════════════════════════════════
   SUGGESTION CARD - Premium Design
   ════════════════════════════════════════════════════════════════════════════ */

.suggestion-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 16px;
    transition: all 0.2s;
    cursor: pointer;
}

.suggestion-card:hover {
    border-color: #c7d2fe;
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.1);
}

.suggestion-card.active {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* Category Badge */
.suggestion-category {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.suggestion-category .category-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.suggestion-category.grammar {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.suggestion-category.grammar .category-dot {
    background: #ef4444;
}

.suggestion-category.spelling {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.suggestion-category.spelling .category-dot {
    background: #f59e0b;
}

.suggestion-category.style {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.suggestion-category.style .category-dot {
    background: #3b82f6;
}

/* Card Header with Ignore Button */
.suggestion-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.suggestion-ignore-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    opacity: 0;
    transition: all 0.2s;
}

.suggestion-card:hover .suggestion-ignore-btn {
    opacity: 1;
}

.suggestion-ignore-btn:hover {
    background: #f3f4f6;
    color: #6b7280;
}

/* Original → Suggestion */
.suggestion-change {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 14px;
}

.suggestion-original {
    color: #9ca3af;
    text-decoration: line-through;
    text-decoration-color: rgba(239, 68, 68, 0.5);
    word-break: break-all;
}

.suggestion-arrow {
    color: #d1d5db;
}

.suggestion-new {
    font-weight: 600;
    color: #111827;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(5, 150, 105, 0.1) 100%);
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    word-break: break-all;
}

/* Reason Text */
.suggestion-reason {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 14px;
}

/* Accept Button */
.suggestion-accept-btn {
    width: 100%;
    padding: 10px 16px;
    background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.suggestion-accept-btn:hover {
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
}

.suggestion-accept-btn:active {
    transform: scale(0.98);
}

/* ════════════════════════════════════════════════════════════════════════════
   EMPTY STATE
   ════════════════════════════════════════════════════════════════════════════ */

.grammar-empty-state {
    text-align: center;
    padding: 32px 16px;
    border: 2px dashed #e5e7eb;
    border-radius: 12px;
}

.grammar-empty-icon {
    font-size: 28px;
    margin-bottom: 8px;
}

.grammar-empty-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

.grammar-empty-subtitle {
    font-size: 12px;
    color: #9ca3af;
}

/* ════════════════════════════════════════════════════════════════════════════
   LOADING ANIMATION - Beautiful Orb
   ════════════════════════════════════════════════════════════════════════════ */

.grammar-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
}

.grammar-loading-orb {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 24px;
}

.grammar-loading-orb .orb-outer {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.4) 0%, rgba(168, 85, 247, 0.2) 50%, transparent 70%);
    border-radius: 50%;
    filter: blur(15px);
    animation: orbPulse 2s ease-in-out infinite;
}

.grammar-loading-orb .orb-middle {
    position: absolute;
    inset: 15px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.6) 0%, rgba(139, 92, 246, 0.4) 50%, transparent 70%);
    border-radius: 50%;
    filter: blur(10px);
    animation: orbPulse 2s ease-in-out infinite 0.3s;
}

.grammar-loading-orb .orb-ring {
    position: absolute;
    inset: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    animation: orbPulse 2s ease-in-out infinite;
}

.grammar-loading-orb .orb-core {
    position: absolute;
    inset: 25px;
    background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 50%, #a855f7 100%);
    border-radius: 50%;
    animation: orbPulse 2s ease-in-out infinite;
}

.grammar-loading-orb .orb-highlight {
    position: absolute;
    inset: 30px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, rgba(236, 72, 153, 0.3) 50%, transparent 100%);
    border-radius: 50%;
    animation: orbPulse 2s ease-in-out infinite;
}

@keyframes orbPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

.grammar-loading-text {
    text-align: center;
}

.grammar-loading-title {
    font-size: 16px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 4px;
    animation: pulse 2s ease-in-out infinite;
}

.grammar-loading-subtitle {
    font-size: 12px;
    color: #9ca3af;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.grammar-loading-dots {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.grammar-loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.grammar-loading-dots span:nth-child(1) {
    background: #8b5cf6;
    animation-delay: 0s;
}

.grammar-loading-dots span:nth-child(2) {
    background: #a855f7;
    animation-delay: 0.2s;
}

.grammar-loading-dots span:nth-child(3) {
    background: #3b82f6;
    animation-delay: 0.4s;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* ════════════════════════════════════════════════════════════════════════════
   ERROR HIGHLIGHTING IN EDITOR
   ════════════════════════════════════════════════════════════════════════════ */

.error-highlight {
    cursor: pointer;
    padding: 1px 3px;
    border-radius: 3px;
    transition: all 0.2s;
    border-bottom: 3px solid;
}

/* Grammar errors - Red */
.error-highlight-grammar {
    background: rgba(239, 68, 68, 0.15);
    border-bottom-color: #ef4444;
}

.error-highlight-grammar:hover {
    background: rgba(239, 68, 68, 0.25);
}

/* Spelling errors - Orange */
.error-highlight-spelling {
    background: rgba(245, 158, 11, 0.15);
    border-bottom-color: #f59e0b;
}

.error-highlight-spelling:hover {
    background: rgba(245, 158, 11, 0.25);
}

/* Style suggestions - Blue */
.error-highlight-style {
    background: rgba(59, 130, 246, 0.15);
    border-bottom-color: #3b82f6;
}

.error-highlight-style:hover {
    background: rgba(59, 130, 246, 0.25);
}

/* ════════════════════════════════════════════════════════════════════════════
   TOOLTIP
   ════════════════════════════════════════════════════════════════════════════ */

.grammar-tooltip {
    position: fixed;
    z-index: 9999;
    padding: 12px 16px;
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -100%) translateY(-8px);
    transition: opacity 0.15s, transform 0.15s;
}

.grammar-tooltip.visible {
    opacity: 1;
    transform: translate(-50%, -100%) translateY(0);
}

.grammar-tooltip-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.grammar-tooltip-original {
    color: #f87171;
    text-decoration: line-through;
}

.grammar-tooltip-arrow-text {
    color: #6b7280;
}

.grammar-tooltip-suggestion {
    color: #4ade80;
    font-weight: 600;
}

/* Tooltip arrow */
.grammar-tooltip::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -6px;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: rgba(17, 24, 39, 0.95);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* ════════════════════════════════════════════════════════════════════════════
   TOGGLE BUTTON (when panel is closed)
   ════════════════════════════════════════════════════════════════════════════ */

.grammar-toggle-btn {
    position: fixed;
    top: 100px;
    right: 16px;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    z-index: 999;
    transition: all 0.2s;
}

.grammar-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(139, 92, 246, 0.5);
}

.grammar-toggle-btn svg {
    width: 24px;
    height: 24px;
}

/* Badge for issue count */
.grammar-toggle-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    background: #ef4444;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid white;
}

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE - TABLET
   ════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1200px) {
    .grammar-panel {
        width: 300px;
    }
}

@media (max-width: 1024px) {
    .grammar-panel {
        width: 280px;
        right: 8px;
    }

    .grammar-toggle-btn {
        top: 96px;
        width: 44px;
        height: 44px;
    }
}

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE - MOBILE (Bottom Sheet Style)
   ════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .grammar-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 60vh;
        border-radius: 20px 20px 0 0;
        border: none;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
    }

    .grammar-panel-header {
        padding: 12px 16px;
        border-bottom: 1px solid #f3f4f6;
    }

    /* Drag handle indicator for bottom sheet */
    .grammar-panel-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: #d1d5db;
        border-radius: 2px;
    }

    .grammar-panel-title {
        font-size: 15px;
        padding-top: 8px;
    }

    .grammar-panel-close {
        width: 32px;
        height: 32px;
    }

    .grammar-panel-body {
        padding: 12px 16px;
        max-height: calc(60vh - 80px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .grammar-analyze-btn {
        padding: 14px 20px;
        font-size: 15px;
    }

    .grammar-stats {
        gap: 8px;
    }

    .grammar-stat-card {
        padding: 12px;
    }

    .grammar-score {
        font-size: 24px;
    }

    .grammar-suggestions-list {
        gap: 10px;
    }

    .suggestion-card {
        padding: 14px;
        border-radius: 14px;
    }

    .suggestion-change {
        font-size: 15px;
    }

    .suggestion-reason {
        font-size: 13px;
    }

    .suggestion-accept-btn {
        padding: 12px 16px;
        font-size: 14px;
    }

    /* Make ignore button always visible on mobile (no hover) */
    .suggestion-card .suggestion-ignore-btn {
        opacity: 1;
    }

    /* Toggle button on mobile - positioned above zoom indicator */
    .grammar-toggle-btn {
        top: auto;
        bottom: 80px;
        /* Above zoom indicator */
        right: 16px;
        width: 52px;
        height: 52px;
        z-index: 1001;
        /* Above zoom */
    }

    .grammar-toggle-btn svg {
        width: 22px;
        height: 22px;
    }

    /* Tooltip on mobile - simpler positioning */
    .grammar-tooltip {
        position: fixed;
        left: 16px !important;
        right: 16px !important;
        bottom: 80px !important;
        top: auto !important;
        transform: none;
        width: auto;
        max-width: none;
    }

    .grammar-tooltip.visible {
        transform: none;
    }

    .grammar-tooltip::after {
        display: none;
    }

    /* Toast on mobile */
    .grammar-toast {
        left: 16px;
        right: 16px;
        bottom: 80px;
        text-align: center;
    }

    /* Loading state - smaller on mobile */
    .grammar-loading {
        padding: 32px 16px;
    }

    .grammar-loading-orb {
        width: 80px;
        height: 80px;
        margin-bottom: 16px;
    }

    .grammar-empty-state {
        padding: 24px 12px;
    }
}

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE - SMALL MOBILE
   ════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .grammar-panel {
        max-height: 55vh;
    }

    .grammar-panel-body {
        padding: 10px 12px;
    }

    .grammar-stats {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .suggestion-card {
        padding: 12px;
    }

    .suggestion-change {
        font-size: 14px;
    }

    .grammar-toggle-btn {
        width: 48px;
        height: 48px;
        bottom: 16px;
        right: 16px;
    }
}

/* ════════════════════════════════════════════════════════════════════════════
   TOAST NOTIFICATION
   ════════════════════════════════════════════════════════════════════════════ */

.grammar-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    background: #111827;
    color: white;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
}

.grammar-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.grammar-toast.success {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

.grammar-toast.error {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
}