/* text.css - Modern Tabbed Text Sync with App Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Modern Theme Variables (Blue/Orange) */
    --primary: #4A90E2;
    --primary-dark: #357ABD;
    --secondary: #6B9BD1;
    --accent: #FF8F70;
    --dark: #0F172A;
    --light: #F8FAFC;
    --gray: #64748B;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --card-bg: #ffffff;
    --glass-border: rgba(255, 255, 255, 0.6);

    /* Mapping legacy variables to new theme */
    --primary-color: var(--primary);
    --primary-hover: var(--primary-dark);
    --primary-light: #EEF6FF;
    /* Light blue tint */
    --secondary-color: var(--gray);
    --accent-color: var(--accent);
    --success-color: var(--success);
    --danger-color: var(--danger);
    --warning-color: var(--warning);
    --info-color: #3B82F6;
    --dark-color: var(--dark);
    --light-bg: var(--light);
    --white: #FFFFFF;
    --border-color: #E2E8F0;
    --text-primary: var(--dark);
    --text-secondary: var(--gray);

    /* Typography */
    --font-heading: 'Plus Jakarta Sans', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;

    /* Shadows */
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 2px 8px rgba(148, 163, 184, 0.1);
    --shadow-md: 0 8px 24px rgba(148, 163, 184, 0.15);
    --shadow-lg: 0 16px 48px rgba(148, 163, 184, 0.2);
}

/* Global Scrollbar */
body::-webkit-scrollbar {
    width: 8px;
}

body::-webkit-scrollbar-track {
    background: transparent;
}

body::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 4px;
}

body::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* Body */
body {
    background-color: var(--light);
    color: var(--dark);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background-image:
        radial-gradient(at 0% 0%, rgba(74, 144, 226, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(255, 143, 112, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
}

/* Typography Overrides */
h1,
h2,
h3,
h4,
.h1,
.h2,
.h3,
.h4 {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--dark);
}

.text-muted {
    color: var(--gray) !important;
}

.text-primary {
    color: var(--primary) !important;
}

/* ==================== TABS CONTAINER ==================== */

.tabs-container {
    width: 100%;
    margin-bottom: 20px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    /* Prevent wrapping */
    gap: 15px;
}

.tabs-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-start;
    flex: 1;
    /* Allow tabs to take available space */
    min-width: 0;
    /* Allow shrinking */
    overflow-x: auto;
    /* Scroll if too many tabs */
}

/* Sync badge - fixed position */
.sync-status-badge {
    flex-shrink: 0;
    /* Never shrink */
    white-space: nowrap;
    /* Don't wrap text */
}

/* ==================== TAB STYLING ==================== */
/* Pill-style tabs */
.tab {
    background: white;
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 50px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    max-width: 200px;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.tab:hover {
    box-shadow: var(--shadow-md);
    color: var(--primary);
    border-color: rgba(74, 144, 226, 0.3);
}

.tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
    font-weight: 600;
}

/* Remove the old css clip-path shapes */
.tab::before,
.tab::after {
    display: none;
}

.tab-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab-close {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: currentColor;
    opacity: 0.6;
    transition: all 0.2s;
    flex-shrink: 0;
}

.tab-close:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.1);
}

/* ==================== NEW TAB BUTTON ==================== */
.new-tab-button {
    background-color: white;
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 20px;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    margin-left: 5px;
}

.new-tab-button:hover {
    background-color: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

/* ==================== MAIN CARD ==================== */
.main-card {
    background-color: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.5);
    /* Glassy border hint */
    overflow: hidden;
}

/* ==================== TEXT INPUT CONTAINER ==================== */
.text-input-container {
    flex: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    /* Ensure it doesn't exceed parent */
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

.copy-icon-btn {
    position: absolute;
    top: 30px;
    right: 80px;
    background-color: rgba(241, 245, 249, 0.8);
    backdrop-filter: blur(4px);
    border: none;
    border-radius: 12px;
    width: 42px;
    height: 42px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    color: var(--gray);
}

.copy-icon-btn:hover {
    background-color: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* Expand expansion logic same as before but styled cleaner */
.text-input-container.deexpanded {
    min-height: 400px;
    max-height: 600px;
    overflow-y: auto;
}

.text-input-container.expanded {
    min-height: 400px;
    height: auto;
    overflow-y: visible;
}

.text-input {
    width: 100%;
    flex: 1;
    border: none;
    outline: none;
    font-size: 1.1rem;
    font-family: 'Inter', monospace;
    /* Nice mono font */
    color: var(--dark);
    resize: none;
    background-color: transparent;
    line-height: 1.7;
    height: 100%;
    /* Fill container by default */
}

.text-input-container.expanded .text-input {
    flex: none;
    /* Disable flex sizing so auto-height works */
    height: auto;
    min-height: 400px;
    /* Ensure strictly at least 400px */
}

.text-input {
    font-family: var(--font-body);
    /* Or stick to body font for general text */
}

.text-input::placeholder {
    color: #94A3B8;
    font-weight: 400;
}

/* ==================== BUTTON CONTAINER ==================== */
.save-button-container {
    padding: 0 40px 40px 40px;
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    align-items: center;
    background: linear-gradient(to top, white 80%, transparent);
    /* slight fade at bottom if scrolling? no.*/
}

.toggle-expand-button,
.clear-button,
.save-button {
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toggle-expand-button {
    background-color: transparent;
    color: var(--gray);
    margin-right: auto;
    padding-left: 0;
}

.toggle-expand-button:hover {
    color: var(--primary);
}

.clear-button {
    background-color: #F1F5F9;
    color: var(--gray);
}

.clear-button:hover {
    background-color: #E2E8F0;
    color: var(--dark);
}

.save-button {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.save-button:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(74, 144, 226, 0.4);
}

.save-button:active {
    transform: scale(0.98);
}

.save-button.copied {
    background-color: var(--success);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* ==================== TIMER ==================== */
.timer-container {
    width: 100%;
    padding: 15px 40px;
    border-top: 1px solid #F1F5F9;
    background: #FAFAFA;
}

.timer-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gray);
    font-weight: 500;
}

.timer-value {
    color: var(--danger);
    font-weight: 700;
    background: rgba(239, 68, 68, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
}

/* ==================== FEEDBACK ==================== */
.message-feedback {
    padding: 0 40px 15px;
    font-size: 14px;
    text-align: right;
    font-weight: 600;
}

.message-feedback.success {
    color: var(--success);
}

.message-feedback.error {
    color: var(--danger);
}


/* ==================== RESPONSIVE ==================== */
@media (max-width: 991px) {
    .main-card {
        border-radius: var(--radius-md);
    }

    .text-input-container {
        padding: 25px;
    }

    .save-button-container {
        padding: 0 25px 25px;
    }

    /* Show sync badge on tablet */
    .sync-status-badge {
        display: inline-flex !important;
    }
}

@media (max-width: 768px) {
    .tabs-container {
        flex-wrap: wrap;
        /* Allow wrapping on mobile */
        gap: 10px;
    }

    .tabs-wrapper {
        gap: 8px;
        width: 100%;
        /* Full width on mobile */
        order: 1;
    }

    /* Sync badge on second row on mobile */
    .sync-status-badge {
        order: 2;
        width: 100%;
        justify-content: center;
        margin-top: 10px;
        display: inline-flex !important;
        /* Always show on mobile */
    }

    .tab {
        min-width: unset;
        font-size: 13px;
        padding: 8px 14px;
    }

    .new-tab-button {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }

    .copy-icon-btn {
        top: 15px;
        right: 15px;
    }

    .save-button-container {
        flex-direction: column;
        gap: 15px;
    }

    .toggle-expand-button,
    .clear-button,
    .save-button {
        width: 100%;
        margin-right: 0;
        padding: 14px;
    }

    .toggle-expand-button {
        order: 3;
        text-align: center;
        background: #F8FAFC;
    }

    .clear-button {
        order: 2;
    }

    .save-button {
        order: 1;
    }
}

/* Sync Indicator Styles */
.sync-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.pulse-green {
    background: var(--success);
    box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
    animation: pulse-green-animation 2s infinite;
}

@keyframes pulse-green-animation {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}