/* Add Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@300;400;500;600;700&display=swap');

/* Unicode highlighting styles */

@keyframes highlightPulse {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        transform: scale(1.05);
        filter: brightness(1.2);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}
.textarea-wrapper {
    position: relative;
    width: 100%;
    background: #0F0F0F;
    border-radius: 16px;
}

body.light-mode .textarea-wrapper {
    background: #FAFAFA;
}

.highlight-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    padding: 1.25rem;
    margin: 0;
    border: 1px solid transparent;
    border-radius: 16px;
    color: transparent;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
    z-index: 1;
    box-sizing: border-box;
    min-height: 140px;
    letter-spacing: 0;
    word-spacing: 0;
    text-align: left;
    vertical-align: top;
}

.highlight-overlay span.unicode-char {
    background-color: rgba(0, 227, 170, 0.6);
    color: transparent;
    border-radius: 3px;
}

.highlight-overlay span.emoji-char {
    background-color: rgba(255, 71, 133, 0.6);
    color: transparent;
    border-radius: 3px;
}

/* Light mode highlight colors */
body.light-mode .highlight-overlay span.unicode-char {
    background-color: rgba(0, 181, 136, 0.7);
}

body.light-mode .highlight-overlay span.emoji-char {
    background-color: rgba(255, 71, 133, 0.7);
}

.unicode-legend {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 12px;
    opacity: 0.8;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-color.gsm-char {
    background-color: transparent;
    border: 1px solid currentColor;
}

.legend-color.unicode-char {
    background: linear-gradient(180deg, #00E3AA 0%, #00B588 100%);
    box-shadow: 0 0 0 1px rgba(0, 227, 170, 0.3);
}

.legend-color.emoji-char {
    background: linear-gradient(180deg, #FF4785 0%, #FF2E63 100%);
    box-shadow: 0 0 0 1px rgba(255, 71, 133, 0.3);
}

.legend-text {
    font-weight: 400;
}

/* Ensure textarea is positioned above the overlay but transparent enough to show highlights */
.textarea-wrapper #message-text {
    position: relative;
    z-index: 2;
    background-color: transparent;
    caret-color: #00E3AA;
}

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes textReveal {
    0% {
        opacity: 0;
        transform: translateY(100%);
    }
    20% {
        opacity: 1;
        transform: translateY(0);
    }
    80% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-100%);
    }
}

@keyframes marqueeHover {
    0% { transform: translateX(0%); }
    100% { transform: translateX(-100%); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #FFFFFF;
    background: #0A0A0A;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Light mode styles */
body.light-mode {
    color: #000000;
    background: #FFFFFF;
}

body.light-mode .input-section {
    background: #FFFFFF;
    border-color: #E8E8E8;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

body.light-mode .input-section:hover {
    box-shadow: 0 8px 32px rgba(0, 227, 170, 0.1);
    border-color: #00E3AA;
}

body.light-mode .message-input-container label,
body.light-mode .encoding-option label {
    color: #00B588;
}

body.light-mode #message-text {
    background: rgba(250, 250, 250, 0.5);
    border-color: #D1D1D1;
    color: #000000;
}

body.light-mode #encoding-select {
    background: rgba(250, 250, 250, 0.95);
    border-color: #D1D1D1;
    color: #000000;
}

body.light-mode #message-text:focus {
    background: rgba(250, 250, 250, 0.5);
    border-color: #00E3AA;
    box-shadow: 0 0 0 3px rgba(0, 227, 170, 0.15);
}

body.light-mode #encoding-select:focus {
    background: #FFFFFF;
    border-color: #00E3AA;
    box-shadow: 0 0 0 3px rgba(0, 227, 170, 0.15);
}

body.light-mode .character-count {
    color: #666666;
}

body.light-mode .segment-visualization,
body.light-mode .message-details {
    background: #FFFFFF;
    border-color: #E8E8E8;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

body.light-mode .segment-visualization:hover,
body.light-mode .message-details:hover {
    box-shadow: 0 8px 32px rgba(0, 227, 170, 0.1);
    border-color: #00E3AA;
}

body.light-mode .segment-visualization h3 {
    color: #000000;
    background: linear-gradient(90deg, #00B588 0%, #8FCC00 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.light-mode .segment-block {
    background: linear-gradient(135deg, #F0F0F0 0%, #E0E0E0 100%);
    color: #000000;
}

body.light-mode .segment-block:hover {
    background: linear-gradient(135deg, #E0E0E0 0%, #D0D0D0 100%);
    box-shadow: 0 4px 16px rgba(0, 227, 170, 0.3);
    border-color: #00E3AA;
}

body.light-mode .detail-item {
    border-bottom-color: #F0F0F0;
}

body.light-mode .detail-item .label {
    color: #00B588;
}

body.light-mode .detail-item .value {
    color: #000000;
}

body.light-mode .segment-blocks:empty::after {
    color: #999999;
}

body.light-mode .input-section:hover {
    background: linear-gradient(135deg, #FFFFFF 0%, rgba(180, 255, 0, 0.06) 100%);
    box-shadow: 0 8px 32px rgba(0, 227, 170, 0.15), 0 4px 16px rgba(180, 255, 0, 0.1);
    border-color: #8FCC00;
}

body.light-mode .segment-visualization:hover,
body.light-mode .message-details:hover {
    background: linear-gradient(135deg, #FFFFFF 0%, rgba(180, 255, 0, 0.06) 100%);
    box-shadow: 0 8px 32px rgba(0, 227, 170, 0.15), 0 4px 16px rgba(180, 255, 0, 0.1);
    border-color: #8FCC00;
}


.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: transparent;
    color: #FFFFFF;
    padding: 3rem 0 2rem 0;
    text-align: center;
    position: relative;
}

body.light-mode header {
    color: #000000;
}

body.light-mode .header-content h1 {
    color: #000000;
}

body.light-mode .header-content p {
    color: #000000;
}

/* Theme toggle */
.theme-toggle {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1000;
}

.theme-toggle-btn {
    background: #1A1A1A;
    border: 1px solid #2A2A2A;
    border-radius: 50%;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    width: 48px;
    height: 48px;
}

.theme-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 227, 170, 0.2);
    border-color: #00E3AA;
}

.theme-icon {
    transition: all 0.3s ease;
    position: absolute;
    color: #FFFFFF;
}

.theme-toggle-btn .dark-icon {
    opacity: 1;
    transform: rotate(0deg);
}

.theme-toggle-btn .light-icon {
    opacity: 0;
    transform: rotate(180deg);
}

body.light-mode .theme-toggle-btn {
    background: #FFFFFF;
    border-color: #E8E8E8;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

body.light-mode .theme-toggle-btn:hover {
    box-shadow: 0 8px 32px rgba(0, 227, 170, 0.1);
    border-color: #00E3AA;
}

body.light-mode .theme-icon {
    color: #000000;
}

body.light-mode .theme-toggle-btn .light-icon {
    opacity: 1;
    transform: rotate(0deg);
}

body.light-mode .theme-toggle-btn .dark-icon {
    opacity: 0;
    transform: rotate(-180deg);
}

/* Logo styling */
.logo-container {
    margin-bottom: 1.5rem;
    animation: fadeInUp 1s ease-out 0.1s both;
}

.telnyx-logo {
    height: 60px;
    width: auto;
    filter: brightness(0) invert(1); /* Makes logo white for dark mode */
    transition: all 0.3s ease;
}

body.light-mode .telnyx-logo {
    filter: brightness(0) invert(0); /* Makes logo black for light mode */
}

.header-content h1 {
    font-family: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 1rem;
    color: #FFFFFF;
    position: relative;
    z-index: 1;
    font-display: swap;
    overflow: hidden;
    animation: fadeInUp 1s ease-out 0.2s both;
}

.header-content h1::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 227, 170, 0.4), rgba(180, 255, 0, 0.3), transparent);
    animation: marqueeHover 3s ease-in-out infinite;
}

.header-content p {
    font-family: Inter, sans-serif;
    font-size: 1.1rem;
    font-weight: 400;
    max-width: 600px;
    margin: 0 auto;
    opacity: 0.8;
    animation: fadeInUp 1s ease-out 0.6s both;
}

/* Calculator main layout */
.calculator {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    padding: 3rem 0;
    max-width: 1000px;
    margin: 0 auto;
}

/* Input section */
.input-section {
    background: #1A1A1A;
    border-radius: 24px;
    padding: 2.5rem;
    border: 1px solid #2A2A2A;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    animation: slideInLeft 0.8s ease-out 0.8s both;
    transition: all 0.3s ease;
}

.input-section:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(0, 227, 170, 0.15), 0 4px 16px rgba(180, 255, 0, 0.1);
    border-color: #B4FF00;
    background: linear-gradient(135deg, #1A1A1A 0%, rgba(180, 255, 0, 0.08) 100%);
}

.message-input-container {
    margin-bottom: 1.5rem;
}

.message-input-container label {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #00E3AA;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

#message-text {
    width: 100%;
    padding: 1.25rem;
    border: 1px solid #3A3A3A;
    border-radius: 16px;
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    min-height: 140px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: rgba(15, 15, 15, 0.5);
    color: #FFFFFF;
    letter-spacing: 0;
    word-spacing: 0;
    text-align: left;
    vertical-align: top;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

#message-text:focus {
    outline: none;
    border-color: #00E3AA;
    background: rgba(15, 15, 15, 0.5);
    box-shadow: 0 0 0 3px rgba(0, 227, 170, 0.15);
}

.character-count {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: #999999;
    font-weight: 400;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.encoding-option label {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #00E3AA;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

#encoding-select {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 1px solid #3A3A3A;
    border-radius: 16px;
    font-size: 1rem;
    background: #0F0F0F;
    cursor: pointer;
    color: #FFFFFF;
    transition: all 0.2s ease;
}

#encoding-select:focus {
    outline: none;
    border-color: #00E3AA;
    background: #000000;
    box-shadow: 0 0 0 3px rgba(0, 227, 170, 0.15);
}

/* Results section */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    animation: slideInRight 0.8s ease-out 1s both;
}

.segment-visualization {
    background: #1A1A1A;
    border-radius: 24px;
    padding: 2.5rem;
    border: 1px solid #2A2A2A;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.segment-visualization:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(0, 227, 170, 0.15), 0 4px 16px rgba(180, 255, 0, 0.1);
    border-color: #B4FF00;
    background: linear-gradient(135deg, #1A1A1A 0%, rgba(180, 255, 0, 0.08) 100%);
}

.segment-visualization h3 {
    margin-bottom: 1.5rem;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.95rem;
    color: #FFFFFF;
    background: linear-gradient(90deg, #00E3AA 0%, #B4FF00 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.segment-blocks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    min-height: 60px;
    align-items: flex-start;
}

.segment-block {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #2A2A2A 0%, #3A3A3A 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    position: relative;
    animation: fadeInUp 0.5s ease-out both;
    animation-delay: calc(var(--block-index) * 0.1s);
}

.segment-block:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 227, 170, 0.3);
    background: linear-gradient(135deg, #3A3A3A 0%, #4A4A4A 100%);
    border-color: #00E3AA;
}

.segment-block.partial {
    background: #B4FF00;
    color: #000000;
    border-color: #B4FF00;
}

.segment-block.partial:hover {
    background: #C8FF33;
    box-shadow: 0 4px 16px rgba(180, 255, 0, 0.4);
}

/* Message details */
.message-details {
    background: #1A1A1A;
    border-radius: 24px;
    padding: 2.5rem;
    border: 1px solid #2A2A2A;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.message-details:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(0, 227, 170, 0.15), 0 4px 16px rgba(180, 255, 0, 0.1);
    border-color: #B4FF00;
    background: linear-gradient(135deg, #1A1A1A 0%, rgba(180, 255, 0, 0.08) 100%);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid #2A2A2A;
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-item .label {
    font-weight: 500;
    color: #00E3AA;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.detail-item .value {
    font-weight: 600;
    color: #FFFFFF;
    font-size: 1rem;
}

/* Rate limits */
.rate-limits {
    background: #000000;
    color: #FFFFFF;
    border-radius: 24px;
    padding: 2.5rem;
    border: 1px solid #333333;
}

.rate-limits h3 {
    margin-bottom: 1.5rem;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.95rem;
}

.rate-limit-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rate-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #333333;
}

.rate-item:last-child {
    border-bottom: none;
}

.rate-type {
    font-weight: 500;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.rate-value {
    font-weight: 600;
    opacity: 0.95;
}

/* Footer */
footer {
    background: #000000;
    color: #FFFFFF;
    padding: 3rem 0;
    text-align: center;
}

footer p {
    margin-bottom: 0.75rem;
    opacity: 0.85;
    font-weight: 300;
}

footer a {
    color: #00E3AA;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

footer a:hover {
    color: #00F5BB;
    text-decoration: underline;
}

/* Responsive design */
@media (max-width: 768px) {
    .calculator {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 2rem 0;
    }
    
    .input-section,
    .segment-visualization,
    .message-details,
    .rate-limits {
        padding: 2rem;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .segment-blocks {
        justify-content: center;
    }
    
    header {
        padding: 3rem 0;
    }
}

/* Empty state */
.segment-blocks:empty::after {
    content: "Enter a message to see segments";
    color: #666666;
    font-style: italic;
    display: block;
    text-align: center;
    padding: 2rem 1rem;
    width: 100%;
    font-size: 0.9rem;
    opacity: 0.7;
}