:root {
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.tool-container {
    max-width: 100%;
    margin: 0.5rem auto;
    padding: 0 0.5rem;
}

.tool-header {
    text-align: center;
    margin-bottom: 0.75rem;
    padding-top: 3rem;
}

@media (min-width: 769px) {
    .tool-header {
        padding-top: 1rem;
    }
}

.tool-title {
    font-size: 1.5rem;
    font-weight: 900;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.25rem;
}

.invoice-builder {
    margin: 0 auto 0.5rem;
}

@media (max-width: 1024px) {
    .tool-container {
        padding: 0 0.25rem;
        margin: 0.25rem auto;
    }

    .tool-title {
        font-size: 1.2rem;
    }

    .form-card {
        padding: 0.5rem;
        margin-bottom: 0.4rem;
    }

    .form-card h3 {
        font-size: 0.8rem;
        margin-bottom: 0.4rem;
    }

    .form-row label {
        font-size: 0.75rem;
    }

    .form-row input, .form-row textarea, .form-row select {
        font-size: 0.75rem;
        padding: 0.5rem;
    }

    .form-row textarea[rows="6"] {
        min-height: 100px;
    }

    .btn-generate {
        padding: 0.75rem;
        font-size: 0.85rem;
    }

    .add-item-btn {
        font-size: 0.75rem;
        padding: 0.6rem 1rem;
    }

    .item-remove-btn {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }
}

@media (max-width: 768px) {
    .form-row-group {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }

    .item-grid {
        grid-template-columns: 1fr;
        gap: 0.3rem;
    }

    .invoice-item-card {
        padding: 0.4rem;
    }

    .tool-header {
        margin-bottom: 0.5rem;
    }

    .tool-title {
        font-size: 1.1rem;
    }

    .form-row {
        margin-bottom: 0.4rem;
    }

    #templateSelect {
        padding: 0.6rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .tool-container {
        padding: 0;
        margin: 0.1rem auto;
    }

    .form-card {
        border-radius: 6px;
        padding: 0.4rem;
    }

    .form-card h3 {
        font-size: 0.75rem;
    }

    .form-row label {
        font-size: 0.7rem;
    }

    .form-row input, .form-row textarea, .form-row select {
        font-size: 0.7rem;
        padding: 0.4rem;
    }

    .btn-generate {
        padding: 0.6rem;
        font-size: 0.75rem;
    }

    #templateSelect {
        padding: 0.5rem;
        font-size: 0.7rem;
    }
}

.form-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.form-card h3 {
    color: var(--pico-primary);
    margin-bottom: 0.5rem;
    margin-top: 0;
    font-size: 0.85rem;
}

.form-row {
    margin-bottom: 0.5rem;
}

.form-row label {
    display: block;
    margin-bottom: 0.15rem;
    font-weight: 600;
    font-size: 0.7rem;
}

.form-row input, .form-row textarea, .form-row select {
    width: 100%;
    padding: 0.35rem 0.45rem;
    border-radius: 4px;
    border: 1px solid var(--pico-muted-border-color);
    background: rgba(255, 255, 255, 0.05);
    font-size: 0.7rem;
    color: var(--pico-color);
    -webkit-appearance: none;
    appearance: none;
}

/* Better touch targets on mobile */
@media (hover: none) and (pointer: coarse) {
    .form-row input, .form-row textarea, .form-row select {
        min-height: 44px;
        padding: 0.5rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .btn-generate, .add-item-btn {
        min-height: 44px;
    }

    .item-remove-btn {
        min-height: 36px;
        min-width: 60px;
    }
}

#templateSelect {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border: 2px solid var(--pico-primary);
    font-weight: 600;
    cursor: pointer;
    padding: 0.5rem;
}

#templateSelect:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
}

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

.form-row textarea[rows="6"] {
    min-height: 80px;
}

@media (max-width: 768px) {
    .form-row textarea {
        min-height: 60px;
    }

    .form-row textarea[rows="6"] {
        min-height: 120px;
    }
}

.form-row-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.invoice-item-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    position: relative;
}

.item-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 0.4rem;
    margin-bottom: 0.25rem;
}

.item-remove-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.65rem;
    margin-top: 0.25rem;
}

.item-remove-btn:hover {
    background: #dc2626;
}

.add-item-btn {
    background: var(--pico-primary);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.7rem;
    width: 100%;
    margin-top: 0.25rem;
    touch-action: manipulation;
}

.add-item-btn:hover {
    opacity: 0.9;
}

.add-item-btn:active {
    opacity: 0.8;
}

.back-to-tools {
    position: fixed;
    top: 1rem;
    left: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    text-decoration: none;
    border: 2px solid var(--pico-primary);
    background: rgba(102, 126, 234, 0.1);
    backdrop-filter: blur(10px);
    z-index: 1000;
    color: var(--pico-primary);
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.back-to-tools:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateX(-2px);
}

.form-disabled {
    opacity: 0.5;
    pointer-events: none;
    user-select: none;
}

.usage-notice {
    animation: slideIn 0.4s ease-out;
}

.signup-btn-hover:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .back-to-tools {
        font-size: 0.75rem;
        padding: 0.4rem 0.75rem;
        top: 0.5rem;
        left: 0.5rem;
    }
}

@media (max-width: 480px) {
    .back-to-tools {
        font-size: 0.7rem;
        padding: 0.35rem 0.6rem;
    }
}

/* Smooth scrolling for mobile */
@media (max-width: 768px) {
    html {
        scroll-behavior: smooth;
    }

    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

.btn-generate {
    width: 100%;
    padding: 0.6rem;
    font-size: 0.8rem;
    font-weight: 700;
    border-radius: 8px;
    background: var(--gradient-1);
    border: none;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
    touch-action: manipulation; /* Prevents double-tap zoom on mobile */
}

.btn-generate:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-generate:active {
    transform: translateY(0);
}
